Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

784 lines
25 KiB

  1. /* LSCRSUBL.C */
  2. #include "lscrsubl.h"
  3. #include "lsidefs.h"
  4. #include "lsc.h"
  5. #include "lsfetch.h"
  6. #include "getfmtst.h"
  7. #include "setfmtst.h"
  8. #include "fmtres.h"
  9. #include "sublutil.h"
  10. #include "break.h"
  11. #include "prepdisp.h"
  12. #include <limits.h>
  13. #define DO_COMPRESSION fTrue
  14. #define DO_EXPANSION fFalse
  15. static LSERR ErrorInCurrentSubline(PLSC plsc, LSERR error)
  16. {
  17. Assert(GetCurrentSubline(plsc) != NULL);
  18. DestroySublineCore(GetCurrentSubline(plsc),&plsc->lscbk, plsc->pols,
  19. &plsc->lsiobjcontext, plsc->fDontReleaseRuns);
  20. SetCurrentSubline(plsc, NULL);
  21. return error;
  22. }
  23. /* ---------------------------------------------------------------------- */
  24. /* L S C R E A T E S U B L I N E*/
  25. /*----------------------------------------------------------------------------
  26. %%Function: LsCreateSubline
  27. %%Contact: igorzv
  28. Parameters:
  29. plsc - (IN) LS context
  30. cpFirst - (IN) first cp of a subline
  31. urColumnMax - (IN) width restriction for a subline
  32. lstflow - (IN) text flow of a subline
  33. fContiguos - (IN) if TRUE such line has the same coordinate system as main line
  34. and is allowed to have tabs
  35. ----------------------------------------------------------------------------*/
  36. LSERR WINAPI LsCreateSubline(PLSC plsc, LSCP cpFirst, long urColumnMax,
  37. LSTFLOW lstflow, BOOL fContiguos)
  38. {
  39. if (!FIsLSC(plsc)) return lserrInvalidParameter;
  40. if (!FFormattingAllowed(plsc) && !FBreakingAllowed(plsc)) return lserrCreateSublineDisabled;
  41. if (GetCurrentSubline(plsc) != NULL) return lserrCreateSublineDisabled;
  42. if (fContiguos) /* this flag is allowed only in formating time and only within fmt method */
  43. {
  44. if (!FFormattingAllowed(plsc)) return lserrInvalidParameter;
  45. if (GetDnodeToFinish(plsc) == NULL) return lserrInvalidParameter;
  46. if (!(SublineFromDnode(GetDnodeToFinish(plsc))->fContiguous))
  47. fContiguos = fFalse;
  48. }
  49. if (urColumnMax > uLsInfiniteRM)
  50. urColumnMax = uLsInfiniteRM;
  51. return CreateSublineCore(plsc, cpFirst, urColumnMax, lstflow, fContiguos);
  52. }
  53. /* ---------------------------------------------------------------------- */
  54. /* L S F E T C H A P P E N D T O C U R R E N T S U B L I N E*/
  55. /*----------------------------------------------------------------------------
  56. %%Function: LsFetchAppendToCurrentSubline
  57. %%Contact: igorzv
  58. Parameters:
  59. plsc - (IN) LS context
  60. lsdcp - (IN) increse cp before fetching
  61. plsesc - (IN) escape characters
  62. cEsc - (IN) # of escape characters
  63. pfSuccessful- (OUT) Successful?---if not, finish
  64. subline, destroy it and start anew
  65. pfmtres - (OUT) result of last formatter
  66. pcpLim - (OUT) where we stop fetching
  67. pplsdnFirst - (OUT) first dnode that was created
  68. pplsdnLast - (OUT) last dnode that was created
  69. ----------------------------------------------------------------------------*/
  70. LSERR WINAPI LsFetchAppendToCurrentSubline(PLSC plsc, LSDCP lsdcp,
  71. const LSESC* plsesc, DWORD cEsc,
  72. BOOL *pfSuccessful, FMTRES* pfmtres,
  73. LSCP* pcpLim, PLSDNODE* pplsdnFirst,
  74. PLSDNODE* pplsdnLast)
  75. {
  76. LSERR lserr;
  77. PLSSUBL plssubl;
  78. long dur;
  79. long urColumnMaxIncreased;
  80. BOOL fDone = fFalse;
  81. LSSTATE lsstateOld;
  82. BOOL fFirstIteration = fTrue;
  83. PLSDNODE plsdnFirstCurrent;
  84. PLSDNODE plsdnLastCurrent;
  85. if (!FIsLSC(plsc)) return lserrInvalidParameter;
  86. plssubl = GetCurrentSubline(plsc);
  87. if (plssubl == NULL) return lserrFormattingFunctionDisabled;
  88. /* client can use this function only in formatting or breaking time */
  89. if (!FFormattingAllowed(plsc) && !FBreakingAllowed(plsc))
  90. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  91. /* in formatting time it should be some dnode to finish */
  92. if (FFormattingAllowed(plsc) && GetDnodeToFinish(plsc) == NULL)
  93. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  94. /* we don't allow to continue formatting if right margin is exceeded */
  95. if (plssubl->fRightMarginExceeded)
  96. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  97. *pfSuccessful = fTrue;
  98. /* we must to set state to formatting and later restore the old one */
  99. lsstateOld = plssubl->plsc->lsstate;
  100. plssubl->plsc->lsstate = LsStateFormatting;
  101. /*Initialization; */
  102. AdvanceCurrentCpLimSubl(plssubl, lsdcp);
  103. *pplsdnLast = NULL;
  104. urColumnMaxIncreased = RightMarginIncreasing(plsc, plssubl->urColumnMax);
  105. while(!fDone) /* we continue fetching when we have
  106. tab that are not allowed in our subline */
  107. {
  108. lserr = FetchAppendEscCore(plsc, urColumnMaxIncreased, plsesc, cEsc, pfmtres,
  109. pcpLim, &plsdnFirstCurrent, &plsdnLastCurrent, &dur);
  110. if (lserr != lserrNone)
  111. return ErrorInCurrentSubline(plsc, lserr);
  112. Assert((plsdnFirstCurrent == NULL) == (plsdnLastCurrent == NULL));
  113. Assert((plsdnLastCurrent == NULL) || ((plsdnLastCurrent)->plsdnNext == NULL));
  114. if (fFirstIteration)
  115. {
  116. *pplsdnFirst = plsdnFirstCurrent;
  117. fFirstIteration = fFalse;
  118. }
  119. if (plsdnLastCurrent != NULL)
  120. *pplsdnLast = plsdnLastCurrent;
  121. if (*pfmtres == fmtrTab && !plssubl->fContiguous)
  122. {
  123. fDone = fFalse;
  124. }
  125. else
  126. {
  127. fDone = fTrue;
  128. }
  129. }
  130. plsc->lsstate = lsstateOld;
  131. if (*pfmtres == fmtrExceededMargin)
  132. {
  133. if (GetCurrentUrSubl(plssubl) <= plssubl->urColumnMax)
  134. {
  135. *pfSuccessful = fFalse;
  136. if (plsc->lMarginIncreaseCoefficient >= uLsInfiniteRM / 2 )
  137. plsc->lMarginIncreaseCoefficient = uLsInfiniteRM;
  138. else
  139. plsc->lMarginIncreaseCoefficient *= 2; /* increase coefficient to be successful
  140. next time */
  141. return lserrNone;
  142. }
  143. plssubl->fRightMarginExceeded = fTrue;
  144. }
  145. Assert((*pplsdnFirst == NULL) == (*pplsdnLast == NULL));
  146. Assert((*pplsdnLast == NULL) || ((*pplsdnLast)->plsdnNext == NULL));
  147. return lserrNone;
  148. }
  149. /* ---------------------------------------------------------------------- */
  150. /* L S F E T C H A P P E N D T O C U R R E N T S U B L I N E R E S U M E*/
  151. /*----------------------------------------------------------------------------
  152. %%Function: LsFetchAppendToCurrentSublineResume
  153. %%Contact: igorzv
  154. Parameters:
  155. plsc - (IN) LS context
  156. rgbreakrec - (IN) input array of break records
  157. cbreakrec, (IN) number of records in input array
  158. lsdcp - (IN) increse cp before fetching
  159. plsesc - (IN) escape characters
  160. cEsc - (IN) # of escape characters
  161. pfSuccessful- (OUT) Successful?---if not, finish
  162. subline, destroy it and start anew
  163. pfmtres - (OUT) result of last formatter
  164. pcpLim - (OUT) where we stop fetching
  165. pplsdnFirst - (OUT) first dnode that was created
  166. pplsdnLast - (OUT) last dnode that was created
  167. ----------------------------------------------------------------------------*/
  168. LSERR WINAPI LsFetchAppendToCurrentSublineResume(PLSC plsc, const BREAKREC* rgbreakrec,
  169. DWORD cbreakrec, LSDCP lsdcp, const LSESC* plsesc,
  170. DWORD cEsc, BOOL *pfSuccessful,
  171. FMTRES* pfmtres, LSCP* pcpLim, PLSDNODE* pplsdnFirst,
  172. PLSDNODE* pplsdnLast)
  173. {
  174. LSERR lserr;
  175. PLSSUBL plssubl;
  176. long dur;
  177. long urColumnMaxIncreased;
  178. BOOL fDone = fFalse;
  179. LSSTATE lsstateOld;
  180. BOOL fFirstIteration = fTrue;
  181. PLSDNODE plsdnFirstCurrent;
  182. PLSDNODE plsdnLastCurrent;
  183. if (!FIsLSC(plsc)) return lserrInvalidParameter;
  184. plssubl = GetCurrentSubline(plsc);
  185. if (plssubl == NULL) return lserrFormattingFunctionDisabled;
  186. /* client can use this function only in formatting or breaking time */
  187. if (!FFormattingAllowed(plsc) && !FBreakingAllowed(plsc))
  188. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  189. /* in formatting time it should be some dnode to finish */
  190. if (FFormattingAllowed(plsc) && GetDnodeToFinish(plsc) == NULL)
  191. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  192. /* subline should be empty to use this function */
  193. if (GetCurrentDnode(plsc) != NULL)
  194. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  195. /* we don't allow to continue formatting if right margin is exceeded */
  196. if (plssubl->fRightMarginExceeded)
  197. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  198. *pfSuccessful = fTrue;
  199. /* we must to set state to formatting and later restore the old one */
  200. lsstateOld = plssubl->plsc->lsstate;
  201. plssubl->plsc->lsstate = LsStateFormatting;
  202. /*Initialization; */
  203. AdvanceCurrentCpLimSubl(plssubl, lsdcp);
  204. *pplsdnLast = NULL;
  205. urColumnMaxIncreased = RightMarginIncreasing(plsc, plssubl->urColumnMax);
  206. while(!fDone) /* we continue fetching when we have
  207. tab that are not allowed in our subline */
  208. {
  209. if (fFirstIteration)
  210. {
  211. lserr = FetchAppendEscResumeCore(plsc, urColumnMaxIncreased, plsesc, cEsc, rgbreakrec,
  212. cbreakrec,pfmtres, pcpLim, &plsdnFirstCurrent,
  213. &plsdnLastCurrent, &dur);
  214. }
  215. else
  216. {
  217. lserr = FetchAppendEscCore(plsc, urColumnMaxIncreased, plsesc, cEsc, pfmtres,
  218. pcpLim, &plsdnFirstCurrent, &plsdnLastCurrent, &dur);
  219. }
  220. if (lserr != lserrNone)
  221. return ErrorInCurrentSubline(plsc, lserr);
  222. Assert((plsdnFirstCurrent == NULL) == (plsdnLastCurrent == NULL));
  223. Assert((plsdnLastCurrent == NULL) || ((plsdnLastCurrent)->plsdnNext == NULL));
  224. if (fFirstIteration)
  225. {
  226. *pplsdnFirst = plsdnFirstCurrent;
  227. fFirstIteration = fFalse;
  228. }
  229. if (plsdnLastCurrent != NULL)
  230. *pplsdnLast = plsdnLastCurrent;
  231. if (*pfmtres == fmtrTab && !plssubl->fContiguous)
  232. {
  233. fDone = fFalse;
  234. }
  235. else
  236. {
  237. fDone = fTrue;
  238. }
  239. }
  240. plsc->lsstate = lsstateOld;
  241. if (*pfmtres == fmtrExceededMargin)
  242. {
  243. if (GetCurrentUrSubl(plssubl) <= plssubl->urColumnMax)
  244. {
  245. *pfSuccessful = fFalse;
  246. if (plsc->lMarginIncreaseCoefficient >= uLsInfiniteRM / 2 )
  247. plsc->lMarginIncreaseCoefficient = uLsInfiniteRM;
  248. else
  249. plsc->lMarginIncreaseCoefficient *= 2; /* increase coefficient to be successful
  250. next time */
  251. return lserrNone;
  252. }
  253. plssubl->fRightMarginExceeded = fTrue;
  254. }
  255. Assert((*pplsdnFirst == NULL) == (*pplsdnLast == NULL));
  256. Assert((*pplsdnLast == NULL) || ((*pplsdnLast)->plsdnNext == NULL));
  257. return lserrNone;
  258. }
  259. /* ---------------------------------------------------------------------- */
  260. /* L S A P P E N D R U N T O C U R R E N T S U B L I N E*/
  261. /*----------------------------------------------------------------------------
  262. %%Function: LsAppendRunToCurrentSubline
  263. %%Contact: igorzv
  264. Parameters:
  265. plsc - (IN) LS context
  266. plsfrun - (IN) given run
  267. pfSuccessful- (OUT) Successful?---if not, finish
  268. subline, destroy it and start anew
  269. pfmtres - (OUT) result of last formatter
  270. pcpLim - (OUT) where we stop fetching
  271. pplsdn - (OUT) dnode created
  272. ----------------------------------------------------------------------------*/
  273. LSERR WINAPI LsAppendRunToCurrentSubline(PLSC plsc, const LSFRUN* plsfrun, BOOL *pfSuccessful,
  274. FMTRES* pfmtres, LSCP* pcpLim, PLSDNODE* pplsdn)
  275. {
  276. LSERR lserr;
  277. PLSSUBL plssubl;
  278. LSSTATE lsstateOld;
  279. long urColumnMaxIncreased;
  280. if (!FIsLSC(plsc)) return lserrInvalidParameter;
  281. plssubl = GetCurrentSubline(plsc);
  282. if (plssubl == NULL) return lserrFormattingFunctionDisabled;
  283. /* client can use this function only in formatting or breaking time */
  284. if (!FFormattingAllowed(plsc) && !FBreakingAllowed(plsc))
  285. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  286. /* in formatting time it should be some dnode to finish */
  287. if (FFormattingAllowed(plsc) && GetDnodeToFinish(plsc) == NULL)
  288. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  289. /* we don't allow to continue formatting if right margin is exceeded */
  290. if (plssubl->fRightMarginExceeded)
  291. return ErrorInCurrentSubline(plsc, lserrFormattingFunctionDisabled);
  292. *pfSuccessful = fTrue;
  293. /* we must to set state to formatting and later restore the old one */
  294. lsstateOld = plssubl->plsc->lsstate;
  295. plssubl->plsc->lsstate = LsStateFormatting;
  296. urColumnMaxIncreased = RightMarginIncreasing(plsc, plssubl->urColumnMax);
  297. lserr = ProcessOneRun(plsc, urColumnMaxIncreased, plsfrun, NULL, 0, pfmtres);
  298. if (lserr != lserrNone)
  299. return ErrorInCurrentSubline(plsc, lserr);
  300. plsc->lsstate = lsstateOld;
  301. if (*pfmtres == fmtrExceededMargin)
  302. {
  303. if (GetCurrentUrSubl(plssubl) <= plssubl->urColumnMax)
  304. {
  305. *pfSuccessful = fFalse;
  306. if (plsc->lMarginIncreaseCoefficient >= uLsInfiniteRM / 2 )
  307. plsc->lMarginIncreaseCoefficient = uLsInfiniteRM;
  308. else
  309. plsc->lMarginIncreaseCoefficient *= 2; /* increase coefficient to be successful
  310. next time */
  311. return lserrNone;
  312. }
  313. plssubl->fRightMarginExceeded = fTrue;
  314. }
  315. /* prepare output */
  316. *pplsdn = GetCurrentDnodeSubl(plssubl);
  317. *pcpLim = GetCurrentCpLimSubl(plssubl);
  318. return lserrNone;
  319. }
  320. /* ---------------------------------------------------------------------- */
  321. /* L S R E S E T R M I N C U R R E N T S U B L I N E*/
  322. /*----------------------------------------------------------------------------
  323. %%Function: LsResetRMInCurrentSubline
  324. %%Contact: igorzv
  325. Parameters:
  326. plsc - (IN) LS context
  327. urColumnMax - (IN) new value of right margin
  328. ----------------------------------------------------------------------------*/
  329. LSERR WINAPI LsResetRMInCurrentSubline(PLSC plsc, long urColumnMax)
  330. {
  331. PLSSUBL plssubl;
  332. if (!FIsLSC(plsc)) return lserrInvalidParameter;
  333. plssubl = GetCurrentSubline(plsc);
  334. if (plssubl == NULL) return lserrCurrentSublineDoesNotExist;
  335. /* we don't allow to change right margin if it is exceeded */
  336. if (plssubl->fRightMarginExceeded) return lserrFormattingFunctionDisabled;
  337. Assert(FIsLSSUBL(plssubl));
  338. plssubl->urColumnMax = urColumnMax;
  339. return lserrNone;
  340. }
  341. /* ---------------------------------------------------------------------- */
  342. /* L S F I N I S H C U R R E N T S U B L I N E*/
  343. /*----------------------------------------------------------------------------
  344. %%Function: LsFinishCurrentSubline
  345. %%Contact: igorzv
  346. Parameters:
  347. plsc - (IN) LS context
  348. pplssubl - (OUT) subline context
  349. ----------------------------------------------------------------------------*/
  350. LSERR WINAPI LsFinishCurrentSubline(PLSC plsc, PLSSUBL* pplssubl)
  351. {
  352. if (!FIsLSC(plsc)) return lserrInvalidParameter;
  353. *pplssubl = GetCurrentSubline(plsc);
  354. if (*pplssubl == NULL) return lserrCurrentSublineDoesNotExist;
  355. Assert(FIsLSSUBL(*pplssubl));
  356. return FinishSublineCore(*pplssubl);
  357. }
  358. /* ---------------------------------------------------------------------- */
  359. /* L S T R U N C A T E S U B L I N E*/
  360. /*----------------------------------------------------------------------------
  361. %%Function: LsTruncateSubline
  362. %%Contact: igorzv
  363. Parameters:
  364. plsc - (IN) LS context
  365. urColumnMax - (IN) right margin
  366. pcpTruncate - (OUT) truncation point
  367. ----------------------------------------------------------------------------*/
  368. LSERR WINAPI LsTruncateSubline(PLSSUBL plssubl, long urColumnMax, LSCP* pcpTruncate)
  369. {
  370. LSERR lserr;
  371. LSSTATE lsstateOld;
  372. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  373. /* it's error if urColumnmMax is biger then lenght of subline */
  374. if (urColumnMax >= GetCurrentUrSubl(plssubl)) return lserrInvalidParameter;
  375. /* we must to set state to breaking and later restore the old one */
  376. lsstateOld = plssubl->plsc->lsstate;
  377. plssubl->plsc->lsstate = LsStateBreaking;
  378. lserr = TruncateSublineCore(plssubl, urColumnMax, pcpTruncate);
  379. plssubl->plsc->lsstate = lsstateOld;
  380. return lserr;
  381. }
  382. /* ---------------------------------------------------------------------- */
  383. /* L S F I N D P R E V B R E A K S U B L I N E*/
  384. /*----------------------------------------------------------------------------
  385. %%Function: LsFindPrevBreakSubline
  386. %%Contact: igorzv
  387. Parameters:
  388. plssubl - (IN) subline context
  389. fFirstSubline - (IN) to apply rules for first character to the first character of
  390. this subline
  391. cpTruncate - (IN) truncation point
  392. urColumnMax - (IN) right margin
  393. pfSuccessful - (OUT) do we find break?
  394. pcpBreak - (OUT) position of break
  395. pobjdimSubline - (OUT) objdim from begining of the subline up to break
  396. pbkpos - (OUT) Before/Inside/After
  397. ----------------------------------------------------------------------------*/
  398. LSERR WINAPI LsFindPrevBreakSubline(PLSSUBL plssubl, BOOL fFirstSubline, LSCP cpTruncate,
  399. long urColumnMax, BOOL* pfSuccessful, LSCP* pcpBreak,
  400. POBJDIM pobjdimSubline, BRKPOS* pbkpos)
  401. {
  402. LSERR lserr;
  403. LSSTATE lsstateOld;
  404. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  405. /* we must to set state to breaking and later retore the old one */
  406. lsstateOld = plssubl->plsc->lsstate;
  407. plssubl->plsc->lsstate = LsStateBreaking;
  408. lserr = FindPrevBreakSublineCore(plssubl, fFirstSubline, cpTruncate, urColumnMax,
  409. pfSuccessful, pcpBreak, pobjdimSubline, pbkpos);
  410. plssubl->plsc->lsstate = lsstateOld;
  411. return lserr;
  412. }
  413. /* ---------------------------------------------------------------------- */
  414. /* L S F I N D N E X T B R E A K S U B L I N E*/
  415. /*----------------------------------------------------------------------------
  416. %%Function: LsFindNextBreakSubline
  417. %%Contact: igorzv
  418. Parameters:
  419. plssubl - (IN) subline context
  420. fFirstSubline - (IN) to apply rules for first character to the first character of
  421. this subline
  422. cpTruncate - (IN) truncation point
  423. urColumnMax - (IN) right margin
  424. pfSuccessful - (OUT) do we find break?
  425. pcpBreak - (OUT) position of break
  426. pobjdimSubline - (OUT) objdim from begining of the subline up to break
  427. pbkpos - (OUT) Before/Inside/After
  428. ----------------------------------------------------------------------------*/
  429. LSERR WINAPI LsFindNextBreakSubline(PLSSUBL plssubl, BOOL fFirstSubline, LSCP cpTruncate,
  430. long urColumnMax, BOOL* pfSuccessful, LSCP* pcpBreak,
  431. POBJDIM pobjdimSubline, BRKPOS* pbkpos)
  432. {
  433. LSERR lserr;
  434. LSSTATE lsstateOld;
  435. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  436. /* we must to set state to breaking and later retore the old one */
  437. lsstateOld = plssubl->plsc->lsstate;
  438. plssubl->plsc->lsstate = LsStateBreaking;
  439. lserr = FindNextBreakSublineCore(plssubl, fFirstSubline, cpTruncate, urColumnMax,
  440. pfSuccessful, pcpBreak, pobjdimSubline, pbkpos);
  441. plssubl->plsc->lsstate = lsstateOld;
  442. return lserr;
  443. }
  444. /* ---------------------------------------------------------------------- */
  445. /* L S F O R C E B R E A K S U B L I N E*/
  446. /*----------------------------------------------------------------------------
  447. %%Function: LsForceBreakSubline
  448. %%Contact: igorzv
  449. Parameters:
  450. plssubl - (IN) subline context
  451. fFirstSubline - (IN) to apply rules for first character to the first character of
  452. this subline
  453. cpTruncate - (IN) truncation point
  454. urColumnMax - (IN) right margin
  455. pcpBreak - (OUT) position of break
  456. pobjdimSubline - (OUT) objdim from begining of the subline up to break
  457. pbkpos - (OUT) Before/Inside/After
  458. ----------------------------------------------------------------------------*/
  459. LSERR WINAPI LsForceBreakSubline(PLSSUBL plssubl, BOOL fFirstSubline, LSCP cpTruncate,
  460. long urColumnMax, LSCP* pcpBreak,
  461. POBJDIM pobjdimSubline, BRKPOS* pbkpos)
  462. {
  463. LSERR lserr;
  464. LSSTATE lsstateOld;
  465. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  466. /* we must to set state to breaking and later retore the old one */
  467. lsstateOld = plssubl->plsc->lsstate;
  468. plssubl->plsc->lsstate = LsStateBreaking;
  469. lserr = ForceBreakSublineCore(plssubl, fFirstSubline, cpTruncate, urColumnMax,
  470. pcpBreak, pobjdimSubline, pbkpos);
  471. plssubl->plsc->lsstate = lsstateOld;
  472. return lserr;
  473. }
  474. /* ---------------------------------------------------------------------- */
  475. /* L S S E T B R E A K S U B L I N E*/
  476. /*----------------------------------------------------------------------------
  477. %%Function: LsSetBreakSubline
  478. %%Contact: igorzv
  479. Parameters:
  480. plssubl - (IN) subline context
  481. brkkind, - (IN) Prev/Next/Force/Imposed
  482. breakrecMaxCurrent - (IN) size of array
  483. pbreakrecCurrent - (OUT) array of break records
  484. pbreakrecMacCurrent - (OUT) number of used elements of the array
  485. ----------------------------------------------------------------------------*/
  486. LSERR WINAPI LsSetBreakSubline(PLSSUBL plssubl, BRKKIND brkkind, DWORD breakrecMaxCurrent,
  487. BREAKREC* pbreakrecCurrent,
  488. DWORD* pbreakrecMacCurrent)
  489. {
  490. LSERR lserr;
  491. LSSTATE lsstateOld;
  492. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  493. /* we must to set state to breaking and later retore the old one */
  494. lsstateOld = plssubl->plsc->lsstate;
  495. plssubl->plsc->lsstate = LsStateBreaking;
  496. lserr = SetBreakSublineCore(plssubl, brkkind, breakrecMaxCurrent,
  497. pbreakrecCurrent, pbreakrecMacCurrent);
  498. plssubl->plsc->lsstate = lsstateOld;
  499. return lserr;
  500. }
  501. /* ---------------------------------------------------------------------- */
  502. /* L S D E S T R O Y S U B L I N E*/
  503. /*----------------------------------------------------------------------------
  504. %%Function: LsDestroySubline
  505. %%Contact: igorzv
  506. Parameters:
  507. plssubl - (IN) subline context
  508. ----------------------------------------------------------------------------*/
  509. LSERR WINAPI LsDestroySubline(PLSSUBL plssubl)
  510. {
  511. PLSC plsc;
  512. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  513. plsc = plssubl->plsc;
  514. Assert(FIsLSC(plsc));
  515. return DestroySublineCore(plssubl,&plsc->lscbk, plsc->pols,
  516. &plsc->lsiobjcontext, plsc->fDontReleaseRuns);
  517. }
  518. /* ---------------------------------------------------------------------- */
  519. /* L S M A T C H P R E S S U B L I N E*/
  520. /*----------------------------------------------------------------------------
  521. %%Function: LsMatchPresSubline
  522. %%Contact: igorzv
  523. Parameters:
  524. plssubl - (IN) subline context
  525. ----------------------------------------------------------------------------*/
  526. LSERR WINAPI LsMatchPresSubline(PLSSUBL plssubl)
  527. {
  528. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  529. return MatchPresSubline(plssubl);
  530. }
  531. /* ---------------------------------------------------------------------- */
  532. /* L S E X P A N D S U B L I N E*/
  533. /*----------------------------------------------------------------------------
  534. %%Function: LsExpandSubline
  535. %%Contact: igorzv
  536. Parameters:
  537. plssubl - (IN) subline context
  538. lskjust - (IN) justification type
  539. dup - (IN) amount to expand
  540. ----------------------------------------------------------------------------*/
  541. LSERR WINAPI LsExpandSubline(PLSSUBL plssubl, LSKJUST lskjust, long dup)
  542. {
  543. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  544. return AdjustSubline(plssubl, lskjust, dup, DO_EXPANSION);
  545. }
  546. /* ---------------------------------------------------------------------- */
  547. /* L S C O M P R E S S S U B L I N E*/
  548. /*----------------------------------------------------------------------------
  549. %%Function: LsCompressSubline
  550. %%Contact: igorzv
  551. Parameters:
  552. plssubl - (IN) subline context
  553. lskjust - (IN) justification type
  554. dup - (IN) amount to compress
  555. ----------------------------------------------------------------------------*/
  556. LSERR WINAPI LsCompressSubline(PLSSUBL plssubl, LSKJUST lskjust, long dup)
  557. {
  558. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  559. return AdjustSubline(plssubl, lskjust, dup, DO_COMPRESSION);
  560. }
  561. /* ---------------------------------------------------------------------- */
  562. /* L S G E T S P E C I A L E F F E C T S S U B L I N E*/
  563. /*----------------------------------------------------------------------------
  564. %%Function: LsGetSpecialEffectsSubline
  565. %%Contact: igorzv
  566. Parameters:
  567. plssubl - (IN) subline context
  568. pfSpecialEffects - (OUT)special effects
  569. ----------------------------------------------------------------------------*/
  570. LSERR WINAPI LsGetSpecialEffectsSubline(PLSSUBL plssubl, UINT* pfSpecialEffects)
  571. {
  572. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  573. return GetSpecialEffectsSublineCore(plssubl, &(plssubl->plsc->lsiobjcontext),
  574. pfSpecialEffects);
  575. }
  576. /* ---------------------------------------------------------------------- */
  577. /* L S S Q U E E Z E S U B L I N E*/
  578. /*----------------------------------------------------------------------------
  579. %%Function: LsSqueezeSubline
  580. %%Contact: igorzv
  581. Parameters:
  582. plssubl - (IN) subline context
  583. durTarget - (IN) target width of subline
  584. pfSuccessful - (OUT)do we achieve the goal
  585. pdurExtra - (OUT)if nof successful, extra dur we have from the goal
  586. ----------------------------------------------------------------------------*/
  587. LSERR WINAPI LsSqueezeSubline(
  588. PLSSUBL plssubl, /* IN: subline context */
  589. long durTarget, /* IN: durTarget */
  590. BOOL* pfSuccessful, /* OUT: fSuccessful? */
  591. long* pdurExtra) /* OUT: if nof successful,
  592. extra dur */
  593. {
  594. LSERR lserr;
  595. LSSTATE lsstateOld;
  596. if (!FIsLSSUBL(plssubl)) return lserrInvalidParameter;
  597. /* we must to set state to breaking and later retore the old one */
  598. lsstateOld = plssubl->plsc->lsstate;
  599. plssubl->plsc->lsstate = LsStateBreaking;
  600. lserr = SqueezeSublineCore(plssubl, durTarget, pfSuccessful, pdurExtra);
  601. plssubl->plsc->lsstate = lsstateOld;
  602. return lserr;
  603. }