outlvw.cxx (75d1e890) | outlvw.cxx (af89ca6e) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 174 unchanged lines hidden (view full) --- 183 if ( ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) && 184 ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TITLEOBJECT ) && 185 ( bSelection || !aSel.nStartPos ) ) 186 { 187 Indent( aKeyCode.IsShift() ? (-1) : (+1) ); 188 bKeyProcessed = sal_True; 189 } 190 else if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) && | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 174 unchanged lines hidden (view full) --- 183 if ( ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) && 184 ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TITLEOBJECT ) && 185 ( bSelection || !aSel.nStartPos ) ) 186 { 187 Indent( aKeyCode.IsShift() ? (-1) : (+1) ); 188 bKeyProcessed = sal_True; 189 } 190 else if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) && |
191 !bSelection && !aSel.nEndPos && pOwner->ImplHasBullet( aSel.nEndPara ) ) | 191 !bSelection && !aSel.nEndPos && pOwner->ImplHasNumberFormat( aSel.nEndPara ) ) |
192 { 193 Indent( aKeyCode.IsShift() ? (-1) : (+1) ); 194 bKeyProcessed = sal_True; 195 } 196 } 197 } 198 break; 199 case KEY_BACKSPACE: --- 980 unchanged lines hidden (view full) --- 1180 } 1181 1182 return nPages; 1183} 1184 1185 1186void OutlinerView::ToggleBullets() 1187{ | 192 { 193 Indent( aKeyCode.IsShift() ? (-1) : (+1) ); 194 bKeyProcessed = sal_True; 195 } 196 } 197 } 198 break; 199 case KEY_BACKSPACE: --- 980 unchanged lines hidden (view full) --- 1180 } 1181 1182 return nPages; 1183} 1184 1185 1186void OutlinerView::ToggleBullets() 1187{ |
1188 pOwner->UndoActionStart( OLUNDO_DEPTH ); | 1188 pOwner->UndoActionStart( OLUNDO_DEPTH ); |
1189 | 1189 |
1190 ESelection aSel( pEditView->GetSelection() ); 1191 aSel.Adjust(); | 1190 ESelection aSel( pEditView->GetSelection() ); 1191 aSel.Adjust(); |
1192 | 1192 |
1193 const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); 1194 pOwner->pEditEngine->SetUpdateMode( sal_False ); | 1193 const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); 1194 pOwner->pEditEngine->SetUpdateMode( sal_False ); |
1195 | 1195 |
1196 sal_Int16 nDepth = -2; | 1196 sal_Int16 nNewDepth = -2; 1197 const SvxNumRule* pDefaultBulletNumRule = 0; |
1197 | 1198 |
1198 for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) 1199 { 1200 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); 1201 DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?"); | 1199 for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) 1200 { 1201 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); 1202 DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?"); |
1202 | 1203 |
1203 if( pPara ) 1204 { 1205 if( nDepth == -2 ) 1206 nDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1; | 1204 if( pPara ) 1205 { 1206 if( nNewDepth == -2 ) 1207 { 1208 nNewDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1; 1209 if ( nNewDepth == 0 ) 1210 { 1211 // determine default numbering rule for bullets 1212 const ESelection aSelection(nPara, 0); 1213 const SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection)); 1214 const SfxPoolItem& rPoolItem = aTmpSet.GetPool()->GetDefaultItem( EE_PARA_NUMBULLET ); 1215 const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(&rPoolItem); 1216 pDefaultBulletNumRule = pNumBulletItem ? pNumBulletItem->GetNumRule() : 0; 1217 } 1218 } |
1207 | 1219 |
1208 pOwner->SetDepth( pPara, nDepth ); | 1220 pOwner->SetDepth( pPara, nNewDepth ); |
1209 | 1221 |
1210 if( nDepth == -1 ) | 1222 if( nNewDepth == -1 ) |
1211 { | 1223 { |
1212 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); 1213 if(rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET) | 1224 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); 1225 if ( rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET ) |
1214 { 1215 SfxItemSet aAttrs(rAttrs); 1216 aAttrs.ClearItem( EE_PARA_BULLETSTATE ); 1217 pOwner->SetParaAttribs( nPara, aAttrs ); 1218 } 1219 } | 1226 { 1227 SfxItemSet aAttrs(rAttrs); 1228 aAttrs.ClearItem( EE_PARA_BULLETSTATE ); 1229 pOwner->SetParaAttribs( nPara, aAttrs ); 1230 } 1231 } |
1220 } 1221 } | 1232 else 1233 { 1234 if ( pDefaultBulletNumRule ) 1235 { 1236 const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat( nPara ); 1237 if ( !pFmt 1238 || ( pFmt->GetNumberingType() != SVX_NUM_BITMAP 1239 && pFmt->GetNumberingType() != SVX_NUM_CHAR_SPECIAL ) ) 1240 { 1241 SfxItemSet aAttrs( pOwner->GetParaAttribs( nPara ) ); 1242 SvxNumRule aNewNumRule( *pDefaultBulletNumRule ); 1243 aAttrs.Put( SvxNumBulletItem( aNewNumRule ), EE_PARA_NUMBULLET ); 1244 pOwner->SetParaAttribs( nPara, aAttrs ); 1245 } 1246 } 1247 } 1248 } 1249 } |
1222 | 1250 |
1223 // --> OD 2009-03-10 #i100014# 1224 // It is not a good idea to substract 1 from a count and cast the result 1225 // to sal_uInt16 without check, if the count is 0. 1226 sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); 1227 // <-- | 1251 const sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); |
1228 pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount ); 1229 pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) ); 1230 | 1252 pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount ); 1253 pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) ); 1254 |
1231 pOwner->pEditEngine->SetUpdateMode( bUpdate ); | 1255 pOwner->pEditEngine->SetUpdateMode( bUpdate ); |
1232 | 1256 |
1233 pOwner->UndoActionEnd( OLUNDO_DEPTH ); | 1257 pOwner->UndoActionEnd( OLUNDO_DEPTH ); |
1234} 1235 | 1258} 1259 |
1236sal_Bool OutlinerView::ToggleBullets(sal_Bool bBulletOnOff, sal_Bool bNormalBullet, sal_Bool bMasterView, SvxNumRule* pNumRule, sal_Bool bForceBulletOnOff) | 1260 1261void OutlinerView::ToggleBulletsNumbering( 1262 const bool bToggle, 1263 const bool bHandleBullets, 1264 const SvxNumRule* pNumRule ) |
1237{ | 1265{ |
1238 pOwner->UndoActionStart( OLUNDO_DEPTH ); | 1266 ESelection aSel( pEditView->GetSelection() ); 1267 aSel.Adjust(); |
1239 | 1268 |
1240 ESelection aSel( pEditView->GetSelection() ); 1241 aSel.Adjust(); | 1269 bool bToggleOn = true; 1270 if ( bToggle ) 1271 { 1272 bToggleOn = false; 1273 const sal_Int16 nBulletNumberingStatus( pOwner->GetBulletsNumberingStatus( aSel.nStartPara, aSel.nEndPara ) ); 1274 if ( nBulletNumberingStatus != 0 && bHandleBullets ) 1275 { 1276 // not all paragraphs have bullets and method called to toggle bullets --> bullets on 1277 bToggleOn = true; 1278 } 1279 else if ( nBulletNumberingStatus != 1 && !bHandleBullets ) 1280 { 1281 // not all paragraphs have numbering and method called to toggle numberings --> numberings on 1282 bToggleOn = true; 1283 } 1284 } 1285 if ( bToggleOn ) 1286 { 1287 // apply bullets/numbering for selected paragraphs 1288 ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle, true ); 1289 } 1290 else 1291 { 1292 // switch off bullets/numbering for selected paragraphs 1293 SwitchOffBulletsNumbering( true ); 1294 } |
1242 | 1295 |
1243 const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); 1244 pOwner->pEditEngine->SetUpdateMode( sal_False ); | 1296 return; 1297} |
1245 | 1298 |
1246 sal_Int16 nDepth = -2; 1247 sal_Bool bRet = sal_False; | |
1248 | 1299 |
1249 //Modified by xuezhiy for bullet enhancement 1250 bool bBulletOn = sal_True; | 1300void OutlinerView::EnableBullets() 1301{ 1302 pOwner->UndoActionStart( OLUNDO_DEPTH ); |
1251 | 1303 |
1252 if( bBulletOnOff ) 1253 { 1254 bool bHasBullet = sal_False; 1255 for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) 1256 { 1257 bHasBullet = pOwner->ImplHasBullet(nPara); 1258 if(bHasBullet) 1259 break; 1260 } | 1304 ESelection aSel( pEditView->GetSelection() ); 1305 aSel.Adjust(); |
1261 | 1306 |
1262 if( bHasBullet ) 1263 { 1264 bBulletOn = sal_False; | 1307 const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); 1308 pOwner->pEditEngine->SetUpdateMode( sal_False ); |
1265 | 1309 |
1266 for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) 1267 { 1268 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); 1269 DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?"); | 1310 for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) 1311 { 1312 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); 1313 DBG_ASSERT(pPara, "OutlinerView::EnableBullets(), illegal selection?"); |
1270 | 1314 |
1271 // const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); 1272 if( pPara ) 1273 { 1274 const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara); 1275 1276 if( !pFmt ) 1277 { 1278 // Has no Bullet paragraph 1279 bBulletOn = sal_True; 1280 break; 1281 } 1282 else if( ( pFmt->GetNumberingType() == SVX_NUM_BITMAP ) || ( pFmt->GetNumberingType() == SVX_NUM_CHAR_SPECIAL ) ) 1283 { 1284 // Normal ==>> Numbering 1285 if( !bNormalBullet ) 1286 { 1287 bBulletOn = sal_True; 1288 break; 1289 } 1290 } 1291 else 1292 { 1293 // Numbering ==>> Normal 1294 if( bNormalBullet ) 1295 { 1296 bBulletOn = sal_True; 1297 break; 1298 } 1299 } 1300 } 1301 } 1302 } | 1315 if( pPara && (pOwner->GetDepth(nPara) == -1) ) 1316 { 1317 pOwner->SetDepth( pPara, 0 ); 1318 } 1319 } |
1303 | 1320 |
1304 } 1305 if (bForceBulletOnOff) { 1306 bBulletOn = bBulletOnOff; 1307 } 1308 for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) 1309 { 1310 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); 1311 DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?"); | 1321 sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); 1322 pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount ); 1323 pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) ); |
1312 | 1324 |
1313 if( pPara ) 1314 { 1315 bRet = sal_True; | 1325 pOwner->pEditEngine->SetUpdateMode( bUpdate ); |
1316 | 1326 |
1317 nDepth = pOwner->GetDepth(nPara); | 1327 pOwner->UndoActionEnd( OLUNDO_DEPTH ); 1328} |
1318 | 1329 |
1319 if( bBulletOn && nDepth == -1 ) 1320 { 1321 // Off ==>> On 1322 nDepth = 0; 1323 } 1324 else if( !bBulletOn && nDepth == 0 ) 1325 { 1326 // On ==>> Off 1327 nDepth = -1; 1328 } 1329 pOwner->SetDepth( pPara, nDepth ); | |
1330 | 1330 |
1331 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); 1332// bool bBulletState = ((const SfxBoolItem&) rAttrs.Get( EE_PARA_BULLETSTATE ) ).GetValue(); | 1331void OutlinerView::ApplyBulletsNumbering( 1332 const bool bHandleBullets, 1333 const SvxNumRule* pNewNumRule, 1334 const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule, 1335 const bool bAtSelection ) 1336{ 1337 if (!pOwner || !pOwner->pEditEngine || !pOwner->pParaList) 1338 { 1339 return; 1340 } |
1333 | 1341 |
1334 SfxItemSet aAttrs(rAttrs); 1335 aAttrs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, bBulletOn ) ); 1336 1337 // Change bullet types 1338 if( bBulletOn && pNumRule) 1339 { 1340 bool bSetBulletType = false; 1341 if( !bBulletOnOff ) 1342 { 1343 // Not bullet on/off button 1344 bSetBulletType = true; 1345 } 1346 else 1347 { 1348 const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara); | 1342 pOwner->UndoActionStart(OLUNDO_DEPTH); 1343 const sal_Bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); 1344 pOwner->pEditEngine->SetUpdateMode(sal_False); |
1349 | 1345 |
1350 if( !pFmt ) 1351 { 1352 // Has no bullet 1353 bSetBulletType = true; 1354 } 1355 else 1356 { 1357 sal_Int16 nNumType = pFmt->GetNumberingType(); 1358 if( bNormalBullet && nNumType != SVX_NUM_BITMAP && nNumType != SVX_NUM_CHAR_SPECIAL ) 1359 { 1360 // Set to Normal bullet, old bullet type is Numbering bullet 1361 bSetBulletType = true; 1362 } 1363 else if( !bNormalBullet && (nNumType == SVX_NUM_BITMAP || nNumType == SVX_NUM_CHAR_SPECIAL) ) 1364 { 1365 // Set to Numbering bullet, old bullet type is Normal bullet 1366 bSetBulletType = true; 1367 } 1368 } 1369 } | 1346 sal_uInt16 nStartPara = 0; 1347 sal_uInt16 nEndPara = 0; 1348 if ( bAtSelection ) 1349 { 1350 ESelection aSel( pEditView->GetSelection() ); 1351 aSel.Adjust(); 1352 nStartPara = aSel.nStartPara; 1353 nEndPara = aSel.nEndPara; 1354 } 1355 else 1356 { 1357 nStartPara = 0; 1358 nEndPara = pOwner->pParaList->GetParagraphCount() - 1; 1359 } |
1370 | 1360 |
1371 // Get old bullet space 1372 SvxNumRule aNewRule( *pNumRule ); | 1361 for (sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++) 1362 { 1363 Paragraph* pPara = pOwner->pParaList->GetParagraph(nPara); 1364 DBG_ASSERT(pPara, "OutlinerView::ApplyBulletsNumbering(..), illegal selection?"); |
1373 | 1365 |
1374 const SfxPoolItem* pPoolItem=NULL; 1375 SfxItemState eState = rAttrs.GetItemState(EE_PARA_NUMBULLET, sal_False, &pPoolItem); 1376 if (eState != SFX_ITEM_SET) 1377 { 1378 // Use default value when has not contain bullet item 1379 ESelection aSelection(nPara, 0); 1380 SfxItemSet aTmpSet( pOwner->pEditEngine->GetAttribs( aSelection ) ); 1381 pPoolItem = aTmpSet.GetItem( EE_PARA_NUMBULLET ); 1382 } | 1366 if (pPara) 1367 { 1368 const sal_Int16 nDepth = pOwner->GetDepth(nPara); 1369 if ( nDepth == -1 ) 1370 { 1371 pOwner->SetDepth( pPara, 0 ); 1372 } |
1383 | 1373 |
1384 const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >( pPoolItem ); 1385 //const SvxNumBulletItem& rNumBullet = (const SvxNumBulletItem&) rAttrs.Get( EE_PARA_NUMBULLET ); 1386 if( pNumBulletItem ) 1387 { 1388 sal_uInt16 nLevelCnt = pNumBulletItem->GetNumRule()->GetLevelCount(); 1389 nLevelCnt = Min( nLevelCnt, pNumRule->GetLevelCount() ); | 1374 const SfxItemSet& rAttrs = pOwner->GetParaAttribs(nPara); 1375 SfxItemSet aAttrs(rAttrs); 1376 aAttrs.Put(SfxBoolItem(EE_PARA_BULLETSTATE, true)); |
1390 | 1377 |
1391 for( sal_uInt16 nLevel = 0; nLevel < nLevelCnt; ++nLevel ) 1392 { 1393 const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule()->Get( nLevel ); 1394 const SvxNumberFormat* pNewFmt = pNumRule->Get( nLevel ); | 1378 // apply new numbering rule 1379 if ( pNewNumRule ) 1380 { 1381 bool bApplyNumRule = false; 1382 if ( !bCheckCurrentNumRuleBeforeApplyingNewNumRule ) 1383 { 1384 bApplyNumRule = true; 1385 } 1386 else 1387 { 1388 const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara); 1389 if (!pFmt) 1390 { 1391 bApplyNumRule = true; 1392 } 1393 else 1394 { 1395 sal_Int16 nNumType = pFmt->GetNumberingType(); 1396 if ( bHandleBullets 1397 && nNumType != SVX_NUM_BITMAP && nNumType != SVX_NUM_CHAR_SPECIAL) 1398 { 1399 // Set to Normal bullet, old bullet type is Numbering bullet. 1400 bApplyNumRule = true; 1401 } 1402 else if ( !bHandleBullets 1403 && (nNumType == SVX_NUM_BITMAP || nNumType == SVX_NUM_CHAR_SPECIAL)) 1404 { 1405 // Set to Numbering bullet, old bullet type is Normal bullet. 1406 bApplyNumRule = true; 1407 } 1408 } 1409 } |
1395 | 1410 |
1396 if( pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() 1397 || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace() ) ) 1398 { 1399 SvxNumberFormat* pNewFmtClone = new SvxNumberFormat( *pNewFmt ); 1400 pNewFmtClone->SetFirstLineOffset( pOldFmt->GetFirstLineOffset() ); 1401 pNewFmtClone->SetAbsLSpace( pOldFmt->GetAbsLSpace() ); | 1411 if ( bApplyNumRule ) 1412 { 1413 SvxNumRule aNewRule(*pNewNumRule); |
1402 | 1414 |
1403 aNewRule.SetLevel( nLevel, pNewFmtClone ); 1404 delete pNewFmtClone; 1405 } 1406 } 1407 } | 1415 // Get old bullet space. 1416 { 1417 const SfxPoolItem* pPoolItem=NULL; 1418 SfxItemState eState = rAttrs.GetItemState(EE_PARA_NUMBULLET, sal_False, &pPoolItem); 1419 if (eState != SFX_ITEM_SET) 1420 { 1421 // Use default value when has not contain bullet item. 1422 ESelection aSelection(nPara, 0); 1423 SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection)); 1424 pPoolItem = aTmpSet.GetItem(EE_PARA_NUMBULLET); 1425 } |
1408 | 1426 |
1409 // Don't set bullet attribute to paragraph in Master view 1410 // Because it will be set into style sheet 1411 if( bSetBulletType && !bMasterView ) 1412 aAttrs.Put(SvxNumBulletItem( aNewRule ), EE_PARA_NUMBULLET); 1413 } | 1427 const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(pPoolItem); 1428 if (pNumBulletItem) 1429 { 1430 const sal_uInt16 nLevelCnt = Min(pNumBulletItem->GetNumRule()->GetLevelCount(), aNewRule.GetLevelCount()); 1431 for ( sal_uInt16 nLevel = 0; nLevel < nLevelCnt; ++nLevel ) 1432 { 1433 const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule()->Get(nLevel); 1434 const SvxNumberFormat* pNewFmt = aNewRule.Get(nLevel); 1435 if (pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace())) 1436 { 1437 SvxNumberFormat* pNewFmtClone = new SvxNumberFormat(*pNewFmt); 1438 pNewFmtClone->SetFirstLineOffset(pOldFmt->GetFirstLineOffset()); 1439 pNewFmtClone->SetAbsLSpace(pOldFmt->GetAbsLSpace()); 1440 aNewRule.SetLevel(nLevel, pNewFmtClone); 1441 delete pNewFmtClone; 1442 } 1443 } 1444 } 1445 } |
1414 | 1446 |
1415 pOwner->SetParaAttribs( nPara, aAttrs ); 1416 1417 } 1418 } | 1447 aAttrs.Put(SvxNumBulletItem(aNewRule), EE_PARA_NUMBULLET); 1448 } 1449 } 1450 pOwner->SetParaAttribs(nPara, aAttrs); 1451 } 1452 } |
1419 | 1453 |
1420 // --> OD 2009-03-10 #i100014# 1421 // It is not a good idea to substract 1 from a count and cast the result 1422 // to sal_uInt16 without check, if the count is 0. 1423 sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); 1424 // <-- 1425 pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount ); 1426 pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) ); | 1454 const sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); 1455 pOwner->ImplCheckParagraphs( nStartPara, nParaCount ); 1456 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nStartPara, 0, nParaCount, 0 ) ); |
1427 | 1457 |
1428 pOwner->pEditEngine->SetUpdateMode( bUpdate ); | 1458 pOwner->pEditEngine->SetUpdateMode( bUpdate ); |
1429 | 1459 |
1430 pOwner->UndoActionEnd( OLUNDO_DEPTH ); | 1460 pOwner->UndoActionEnd( OLUNDO_DEPTH ); |
1431 | 1461 |
1432 return bRet; | 1462 return; |
1433} 1434 | 1463} 1464 |
1435void OutlinerView::EnableBullets() 1436{ 1437 pOwner->UndoActionStart( OLUNDO_DEPTH ); | |
1438 | 1465 |
1439 ESelection aSel( pEditView->GetSelection() ); 1440 aSel.Adjust(); 1441 1442 const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); 1443 pOwner->pEditEngine->SetUpdateMode( sal_False ); 1444 1445 for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ ) 1446 { 1447 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); 1448 DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?"); 1449 1450 if( pPara && (pOwner->GetDepth(nPara) == -1) ) 1451 { 1452 pOwner->SetDepth( pPara, 0 ); 1453 } 1454 } 1455 1456 // --> OD 2009-03-10 #i100014# 1457 // It is not a good idea to substract 1 from a count and cast the result 1458 // to sal_uInt16 without check, if the count is 0. 1459 sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); 1460 // <-- 1461 pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount ); 1462 pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) ); 1463 1464 pOwner->pEditEngine->SetUpdateMode( bUpdate ); 1465 1466 pOwner->UndoActionEnd( OLUNDO_DEPTH ); 1467} 1468 1469sal_Bool OutlinerView::ToggleAllParagraphsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet, sal_Bool bToggleOn, sal_Bool bMasterView, SvxNumRule* pNumRule) | 1466void OutlinerView::SwitchOffBulletsNumbering( 1467 const bool bAtSelection ) |
1470{ | 1468{ |
1471 if (!pOwner || !pOwner->pEditEngine || !pOwner->pParaList) 1472 { 1473 return sal_False; 1474 } | 1469 sal_uInt16 nStartPara = 0; 1470 sal_uInt16 nEndPara = 0; 1471 if ( bAtSelection ) 1472 { 1473 ESelection aSel( pEditView->GetSelection() ); 1474 aSel.Adjust(); 1475 nStartPara = aSel.nStartPara; 1476 nEndPara = aSel.nEndPara; 1477 } 1478 else 1479 { 1480 nStartPara = 0; 1481 nEndPara = pOwner->pParaList->GetParagraphCount() - 1; 1482 } |
1475 | 1483 |
1476 sal_Bool bReturn = sal_False; 1477 pOwner->UndoActionStart(OLUNDO_DEPTH); 1478 const sal_Bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); 1479 pOwner->pEditEngine->SetUpdateMode(sal_False); | 1484 pOwner->UndoActionStart( OLUNDO_DEPTH ); 1485 const bool bUpdate = pOwner->pEditEngine->GetUpdateMode(); 1486 pOwner->pEditEngine->SetUpdateMode( sal_False ); |
1480 | 1487 |
1481 sal_Int16 nDepth = -2; 1482 sal_uInt16 nParaCount = (sal_uInt16)(pOwner->pParaList->GetParagraphCount()); 1483 for (sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) 1484 { 1485 Paragraph* pPara = pOwner->pParaList->GetParagraph(nPara); 1486 DBG_ASSERT(pPara, "OutlinerView::ToggleAllParagraphsBullets(), illegal selection?"); | 1488 for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; ++nPara ) 1489 { 1490 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); 1491 DBG_ASSERT(pPara, "OutlinerView::SwitchOffBulletsNumbering(...), illegal paragraph index?"); |
1487 | 1492 |
1488 if (pPara) 1489 { 1490 bReturn = sal_True; 1491 nDepth = pOwner->GetDepth(nPara); 1492 if (bToggleOn && nDepth == -1) 1493 { 1494 // Off ==>> On 1495 nDepth = 0; 1496 } 1497 else if (!bToggleOn && nDepth == 0) 1498 { 1499 // On ==>> Off 1500 nDepth = -1; 1501 } 1502 pOwner->SetDepth(pPara, nDepth); | 1493 if( pPara ) 1494 { 1495 pOwner->SetDepth( pPara, -1 ); |
1503 | 1496 |
1504 const SfxItemSet& rAttrs = pOwner->GetParaAttribs(nPara); 1505 SfxItemSet aAttrs(rAttrs); 1506 aAttrs.Put(SfxBoolItem(EE_PARA_BULLETSTATE, bToggleOn)); | 1497 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); 1498 if (rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET) 1499 { 1500 SfxItemSet aAttrs(rAttrs); 1501 aAttrs.ClearItem( EE_PARA_BULLETSTATE ); 1502 pOwner->SetParaAttribs( nPara, aAttrs ); 1503 } 1504 } 1505 } |
1507 | 1506 |
1508 // Change bullet types. 1509 if (bToggleOn && pNumRule) 1510 { 1511 sal_Bool bSetBulletType = sal_False; 1512 if (!bBulletOnOffMode) 1513 { 1514 // Not bullet on/off button. 1515 bSetBulletType = sal_True; 1516 } 1517 else 1518 { 1519 const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara); 1520 if (!pFmt) 1521 { 1522 // Has no bullet. 1523 bSetBulletType = sal_True; 1524 } 1525 else 1526 { 1527 sal_Int16 nNumType = pFmt->GetNumberingType(); 1528 if (bNormalBullet && nNumType != SVX_NUM_BITMAP && nNumType != SVX_NUM_CHAR_SPECIAL) 1529 { 1530 // Set to Normal bullet, old bullet type is Numbering bullet. 1531 bSetBulletType = sal_True; 1532 } 1533 else if (!bNormalBullet && (nNumType == SVX_NUM_BITMAP || nNumType == SVX_NUM_CHAR_SPECIAL)) 1534 { 1535 // Set to Numbering bullet, old bullet type is Normal bullet. 1536 bSetBulletType = sal_True; 1537 } 1538 } 1539 } | 1507 const sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount()); 1508 pOwner->ImplCheckParagraphs( nStartPara, nParaCount ); 1509 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nStartPara, 0, nParaCount, 0 ) ); |
1540 | 1510 |
1541 // Get old bullet space. 1542 SvxNumRule aNewRule(*pNumRule); 1543 const SfxPoolItem* pPoolItem=NULL; 1544 SfxItemState eState = rAttrs.GetItemState(EE_PARA_NUMBULLET, sal_False, &pPoolItem); 1545 ESelection aSelection(nPara, 0); 1546 SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection)); 1547 if (eState != SFX_ITEM_SET) 1548 { 1549 // Use default value when has not contain bullet item. 1550 pPoolItem = aTmpSet.GetItem(EE_PARA_NUMBULLET); 1551 } 1552 1553 const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(pPoolItem); 1554 if (pNumBulletItem) 1555 { 1556 sal_uInt16 nLevelCnt = pNumBulletItem->GetNumRule()->GetLevelCount(); 1557 nLevelCnt = Min(nLevelCnt, pNumRule->GetLevelCount()); 1558 1559 for (sal_uInt16 nLevel = 0; nLevel < nLevelCnt; nLevel++) 1560 { 1561 const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule()->Get(nLevel); 1562 const SvxNumberFormat* pNewFmt = pNumRule->Get(nLevel); 1563 if (pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace())) 1564 { 1565 SvxNumberFormat* pNewFmtClone = new SvxNumberFormat(*pNewFmt); 1566 pNewFmtClone->SetFirstLineOffset(pOldFmt->GetFirstLineOffset()); 1567 pNewFmtClone->SetAbsLSpace(pOldFmt->GetAbsLSpace()); 1568 aNewRule.SetLevel(nLevel, pNewFmtClone); 1569 delete pNewFmtClone; 1570 } 1571 } 1572 } 1573 1574 // Don't set bullet attribute to paragraph in Master view, because it will be set into style sheet. 1575 if (bSetBulletType && !bMasterView) 1576 aAttrs.Put(SvxNumBulletItem(aNewRule), EE_PARA_NUMBULLET); 1577 } 1578 pOwner->SetParaAttribs(nPara, aAttrs); 1579 } 1580 } 1581 1582 pOwner->ImplCheckParagraphs(0, nParaCount); 1583 pOwner->pEditEngine->QuickMarkInvalid(ESelection(0, 0, nParaCount, 0)); 1584 pOwner->pEditEngine->SetUpdateMode(bUpdate); 1585 pOwner->UndoActionEnd(OLUNDO_DEPTH); 1586 1587 return bReturn; | 1511 pOwner->pEditEngine->SetUpdateMode( bUpdate ); 1512 pOwner->UndoActionEnd( OLUNDO_DEPTH ); |
1588} 1589 | 1513} 1514 |
1515 |
|
1590void OutlinerView::RemoveAttribsKeepLanguages( sal_Bool bRemoveParaAttribs ) 1591{ 1592 RemoveAttribs( bRemoveParaAttribs, 0, sal_True /*keep language attribs*/ ); 1593} 1594 1595void OutlinerView::RemoveAttribs( sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich, sal_Bool bKeepLanguages ) 1596{ 1597 DBG_CHKTHIS(OutlinerView,0); --- 453 unchanged lines hidden --- | 1516void OutlinerView::RemoveAttribsKeepLanguages( sal_Bool bRemoveParaAttribs ) 1517{ 1518 RemoveAttribs( bRemoveParaAttribs, 0, sal_True /*keep language attribs*/ ); 1519} 1520 1521void OutlinerView::RemoveAttribs( sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich, sal_Bool bKeepLanguages ) 1522{ 1523 DBG_CHKTHIS(OutlinerView,0); --- 453 unchanged lines hidden --- |