summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r--sc/source/ui/dbgui/asciiopt.cxx6
-rw-r--r--sc/source/ui/dbgui/dbnamdlg.cxx1
-rw-r--r--sc/source/ui/dbgui/fieldwnd.cxx1191
-rw-r--r--sc/source/ui/dbgui/filtdlg.cxx59
-rw-r--r--sc/source/ui/dbgui/imoptdlg.cxx35
-rw-r--r--sc/source/ui/dbgui/imoptdlg.hrc1
-rw-r--r--sc/source/ui/dbgui/imoptdlg.src12
-rw-r--r--sc/source/ui/dbgui/pivot.hrc7
-rw-r--r--sc/source/ui/dbgui/pivot.src131
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx12
-rw-r--r--sc/source/ui/dbgui/pvglob.hxx42
-rw-r--r--sc/source/ui/dbgui/pvlaydlg.cxx2099
-rw-r--r--sc/source/ui/dbgui/scendlg.cxx5
-rw-r--r--sc/source/ui/dbgui/scendlg.hrc3
-rw-r--r--sc/source/ui/dbgui/scendlg.src4
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx67
-rw-r--r--sc/source/ui/dbgui/scuiimoptdlg.cxx10
-rw-r--r--sc/source/ui/dbgui/sfiltdlg.cxx7
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx7
-rw-r--r--sc/source/ui/dbgui/tpsubt.cxx3
20 files changed, 1545 insertions, 2157 deletions
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx
index 4e6c61f2e4d0..a518860b1690 100644
--- a/sc/source/ui/dbgui/asciiopt.cxx
+++ b/sc/source/ui/dbgui/asciiopt.cxx
@@ -312,6 +312,10 @@ void ScAsciiOptions::ReadFromString( const String& rString )
aToken = rString.GetToken(7, ',');
bDetectSpecialNumber = aToken.EqualsAscii("true") ? true : false;
}
+ else
+ bDetectSpecialNumber = sal_True; // default of versions that didn't add the parameter
+
+ // 9th token is used for "Save as shown" in export options
}
@@ -399,6 +403,8 @@ String ScAsciiOptions::WriteToString() const
// Detect special nubmers.
aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false");
+ // 9th token is used for "Save as shown" in export options
+
return aOutStr;
}
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index a4a7c6826daa..03fc34eefe2c 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -185,6 +185,7 @@ ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
aBtnDoSize, aBtnKeepFmt, aBtnStripData, theCurArea );
Init();
FreeResource();
+ aRbAssign.SetAccessibleRelationMemberOf(&aFlAssign);
}
diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx
index 8016c20eff34..02bf712e59fb 100644
--- a/sc/source/ui/dbgui/fieldwnd.cxx
+++ b/sc/source/ui/dbgui/fieldwnd.cxx
@@ -28,749 +28,880 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
-#include <vcl/virdev.hxx>
+#include "fieldwnd.hxx"
+
+#include <tools/debug.hxx>
#include <vcl/decoview.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/mnemonic.hxx>
#include <vcl/help.hxx>
-#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/virdev.hxx>
-#include "fieldwnd.hxx"
#include "pvlaydlg.hxx"
-#include "pvglob.hxx"
#include "AccessibleDataPilotControl.hxx"
#include "scresid.hxx"
#include "sc.hrc"
-const size_t INVALID_INDEX = static_cast< size_t >( -1 );
-
-//===================================================================
-
-ScDPFieldWindow::ScDPFieldWindow(
- ScDPLayoutDlg* pDialog,
- const ResId& rResId,
- ScDPFieldType eFieldType,
- FixedText* pFtFieldCaption ) :
- Control( pDialog, rResId ),
- pDlg( pDialog ),
- pFtCaption( pFtFieldCaption ),
- eType( eFieldType ),
- nFieldSelected( 0 ),
- pAccessible( NULL )
-{
- Init();
- if (eType != TYPE_SELECT && pFtCaption)
- aName = MnemonicGenerator::EraseAllMnemonicChars( pFtCaption->GetText() );
-}
-
-ScDPFieldWindow::ScDPFieldWindow(
- ScDPLayoutDlg* pDialog,
- const ResId& rResId,
- ScDPFieldType eFieldType,
- const String& rName ) :
- Control( pDialog, rResId ),
- aName(rName),
- pDlg( pDialog ),
- pFtCaption( NULL ),
- eType( eFieldType ),
- nFieldSelected( 0 ),
- pAccessible( NULL )
-{
- Init();
-}
+// ============================================================================
-void ScDPFieldWindow::Init()
-{
- aWndRect = Rectangle( GetPosPixel(), GetSizePixel() );
- nFieldSize = (eType == TYPE_SELECT) ? PAGE_SIZE : ((eType == TYPE_PAGE) ? MAX_PAGEFIELDS : MAX_FIELDS);
+using namespace ::com::sun::star;
+using ::rtl::OUString;
- if( pFtCaption )
- {
- Size aWinSize( aWndRect.GetSize() );
- Size aTextSize( GetTextWidth( pFtCaption->GetText() ), GetTextHeight() );
- aTextPos.X() = (aWinSize.Width() - aTextSize.Width()) / 2;
- aTextPos.Y() = (aWinSize.Height() - aTextSize.Height()) / 2;
- }
+// ============================================================================
- GetStyleSettings();
-}
+namespace {
-__EXPORT ScDPFieldWindow::~ScDPFieldWindow()
-{
- if (pAccessible)
- {
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (xTempAcc.is())
- pAccessible->dispose();
- }
-}
+/** Line width for insertion cursor in pixels. */
+const long CURSOR_WIDTH = 3;
-//-------------------------------------------------------------------
+/** Number of tracking events before auto scrolling starts. */
+const size_t INITIAL_TRACKING_DELAY = 20;
-void ScDPFieldWindow::GetStyleSettings()
-{
- const StyleSettings& rStyleSet = GetSettings().GetStyleSettings();
- aFaceColor = rStyleSet.GetFaceColor();
- aWinColor = rStyleSet.GetWindowColor();
- aTextColor = rStyleSet.GetButtonTextColor();
- aWinTextColor = rStyleSet.GetWindowTextColor();
-}
+} // namespace
-//-------------------------------------------------------------------
+// ============================================================================
-Point ScDPFieldWindow::GetFieldPosition( size_t nIndex ) const
+ScPivotFieldWindow::ScPivotWindowField::ScPivotWindowField( const ScDPLabelData& rLabelData ) :
+ maFuncData( rLabelData.mnCol, rLabelData.mnFuncMask ),
+ maFieldName( rLabelData.getDisplayName() )
{
- Point aPos;
- switch( eType )
- {
- case TYPE_PAGE:
- aPos.X() = OWIDTH * (nIndex % (MAX_PAGEFIELDS / 2));
- aPos.Y() = OHEIGHT * (nIndex / (MAX_PAGEFIELDS / 2));
- break;
- case TYPE_COL:
- aPos.X() = OWIDTH * (nIndex % (MAX_FIELDS / 2));
- aPos.Y() = OHEIGHT * (nIndex / (MAX_FIELDS / 2));
- break;
- case TYPE_ROW:
- case TYPE_DATA:
- aPos.X() = 0;
- aPos.Y() = OHEIGHT * nIndex;
- break;
- case TYPE_SELECT:
- aPos.X() = (OWIDTH + SSPACE) * (nIndex / LINE_SIZE);
- aPos.Y() = (OHEIGHT + SSPACE) * (nIndex % LINE_SIZE);
- break;
- }
- return aPos;
}
-Size ScDPFieldWindow::GetFieldSize() const
+ScPivotFieldWindow::ScPivotWindowField::ScPivotWindowField( ScPivotLayoutDlg& rDialog, const ScPivotField& rField, bool bDataWindow ) :
+ maFuncData( rField.nCol, rField.nFuncMask, rField.maFieldRef )
{
- return Size( (eType == TYPE_DATA) ? GetSizePixel().Width() : OWIDTH, OHEIGHT );
+ InitFieldName( rDialog, bDataWindow );
}
-Point ScDPFieldWindow::GetLastPosition() const
+ScPivotFieldWindow::ScPivotWindowField::ScPivotWindowField( ScPivotLayoutDlg& rDialog, const ScPivotFuncData& rFuncData, bool bDataWindow ) :
+ maFuncData( rFuncData )
{
- return OutputToScreenPixel( GetFieldPosition( nFieldSize - 1 ) );
+ InitFieldName( rDialog, bDataWindow );
}
-bool ScDPFieldWindow::GetFieldIndex( const Point& rPos, size_t& rnIndex ) const
+void ScPivotFieldWindow::ScPivotWindowField::InitFieldName( ScPivotLayoutDlg& rDialog, bool bDataWindow )
{
- rnIndex = INVALID_INDEX;
- if( (rPos.X() >= 0) && (rPos.Y() >= 0) )
+ if( maFuncData.mnCol != PIVOT_DATA_FIELD )
{
- switch( eType )
+ ScDPLabelData* pLabelData = rDialog.GetLabelData( maFuncData.mnCol );
+ DBG_ASSERT( pLabelData, "ScPivotWindowField::InitFieldName - no label data found" );
+ if( pLabelData )
{
- case TYPE_ROW:
- case TYPE_DATA:
- rnIndex = rPos.Y() / OHEIGHT;
- break;
- case TYPE_PAGE:
- {
- size_t nRow = rPos.Y() / OHEIGHT;
- size_t nCol = rPos.X() / OWIDTH;
- rnIndex = nRow * MAX_PAGEFIELDS / 2 + nCol;
- }
- break;
- case TYPE_COL:
- {
- size_t nRow = rPos.Y() / OHEIGHT;
- size_t nCol = rPos.X() / OWIDTH;
- rnIndex = nRow * MAX_FIELDS / 2 + nCol;
- }
- break;
- case TYPE_SELECT:
+ if( bDataWindow )
{
- size_t nRow = rPos.Y() / (OHEIGHT + SSPACE);
- size_t nCol = rPos.X() / (OWIDTH + SSPACE);
- // is not between controls?
- if( (rPos.Y() % (OHEIGHT + SSPACE) < OHEIGHT) && (rPos.X() % (OWIDTH + SSPACE) < OWIDTH) )
- rnIndex = nCol * LINE_SIZE + nRow;
+ // write original nFuncMask to label data
+ pLabelData->mnFuncMask = maFuncData.mnFuncMask;
+ // GetFuncString() modifies nFuncMask (e.g. auto to sum or count)
+ maFieldName = rDialog.GetFuncString( maFuncData.mnFuncMask, pLabelData->mbIsValue );
}
- break;
+ maFieldName += pLabelData->getDisplayName();
}
}
- return IsValidIndex( rnIndex );
}
-//-------------------------------------------------------------------
-
-void ScDPFieldWindow::DrawBackground( OutputDevice& rDev )
-{
- Point aPos0;
- Size aSize( GetSizePixel() );
+// ============================================================================
- if ( eType == TYPE_SELECT )
- {
- rDev.SetLineColor();
- rDev.SetFillColor( aFaceColor );
- rDev.DrawRect( Rectangle( aPos0, aSize ) );
+ScPivotFieldWindow::ScPivotFieldWindow( ScPivotLayoutDlg* pDialog, const ResId& rResId,
+ ScrollBar& rScrollBar, FixedText* pFtCaption, const OUString& rName,
+ ScPivotFieldType eFieldType, const sal_Char* pcHelpId, PointerStyle eDropPointer,
+ size_t nColCount, size_t nRowCount, long nFieldWidthFactor, long nSpaceSize ) :
+ Control( pDialog, rResId ),
+ mpDialog( pDialog ),
+ mpAccessible( 0 ),
+ mrScrollBar( rScrollBar ),
+ mpFtCaption( pFtCaption ),
+ maName( rName ),
+ meFieldType( eFieldType ),
+ meDropPointer( eDropPointer ),
+ mnColCount( nColCount ),
+ mnRowCount( nRowCount ),
+ mnFirstVisIndex( 0 ),
+ mnSelectIndex( 0 ),
+ mnInsCursorIndex( PIVOTFIELD_INVALID ),
+ mnOldFirstVisIndex( 0 ),
+ mnAutoScrollDelay( 0 ),
+ mbVertical( eFieldType == PIVOTFIELDTYPE_SELECT ),
+ mbIsTrackingSource( false )
+{
+ SetHelpId( pcHelpId );
+
+ mnLineSize = mbVertical ? mnRowCount : mnColCount;
+ mnPageSize = mnColCount * mnRowCount;
+
+ // a single field is 36x12 appfont units
+ maFieldSize = LogicToPixel( Size( 36, 12 ), MapMode( MAP_APPFONT ) );
+ maFieldSize.Width() *= nFieldWidthFactor;
+ maSpaceSize = LogicToPixel( Size( nSpaceSize, nSpaceSize ), MapMode( MAP_APPFONT ) );
+
+ // set window size
+ long nWinWidth = static_cast< long >( mnColCount * maFieldSize.Width() + (mnColCount - 1) * maSpaceSize.Width() );
+ long nWinHeight = static_cast< long >( mnRowCount * maFieldSize.Height() + (mnRowCount - 1) * maSpaceSize.Height() );
+ SetSizePixel( Size( nWinWidth, nWinHeight ) );
+
+ // scroll bar
+ Point aScrollBarPos = GetPosPixel();
+ Size aScrollBarSize( nWinWidth, nWinHeight );
+ if( mbVertical )
+ {
+ aScrollBarPos.Y() += nWinHeight + maSpaceSize.Height();
+ aScrollBarSize.Height() = GetSettings().GetStyleSettings().GetScrollBarSize();
}
else
{
- rDev.SetLineColor( aWinTextColor );
- rDev.SetFillColor( aWinColor );
- rDev.DrawRect( Rectangle( aPos0, aSize ) );
-
- rDev.SetTextColor( aWinTextColor );
-
- /* Draw the caption text. This needs some special handling, because we
- support hard line breaks here. This part will draw each line of the
- text for itself. */
-
- xub_StrLen nTokenCnt = GetText().GetTokenCount( '\n' );
- long nY = (aSize.Height() - nTokenCnt * rDev.GetTextHeight()) / 2;
- for( xub_StrLen nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken )
- {
- String aLine( GetText().GetToken( 0, '\n', nStringIx ) );
- Point aLinePos( (aSize.Width() - rDev.GetCtrlTextWidth( aLine )) / 2, nY );
- rDev.DrawCtrlText( aLinePos, aLine );
- nY += rDev.GetTextHeight();
- }
+ aScrollBarPos.X() += nWinWidth + maSpaceSize.Width();
+ aScrollBarSize.Width() = GetSettings().GetStyleSettings().GetScrollBarSize();
}
+ mrScrollBar.SetPosSizePixel( aScrollBarPos, aScrollBarSize );
+ mrScrollBar.SetLineSize( 1 );
+ mrScrollBar.SetPageSize( static_cast< long >( mbVertical ? mnColCount : mnRowCount ) );
+ mrScrollBar.SetVisibleSize( static_cast< long >( mbVertical ? mnColCount : mnRowCount ) );
+ mrScrollBar.SetScrollHdl( LINK( this, ScPivotFieldWindow, ScrollHdl ) );
+ mrScrollBar.SetEndScrollHdl( LINK( this, ScPivotFieldWindow, ScrollHdl ) );
}
-void ScDPFieldWindow::DrawField(
- OutputDevice& rDev, const Rectangle& rRect, FieldString& rText, bool bFocus )
+ScPivotFieldWindow::~ScPivotFieldWindow()
{
- VirtualDevice aVirDev( rDev );
- // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
- aVirDev.EnableRTL( IsRTLEnabled() );
+ ::rtl::Reference< ScAccessibleDataPilotControl > xAcc = GetAccessibleControl();
+ if( xAcc.is() )
+ xAcc->dispose();
+}
- String aText = rText.first;
- Size aDevSize( rRect.GetSize() );
- long nWidth = aDevSize.Width();
- long nHeight = aDevSize.Height();
- long nLabelWidth = rDev.GetTextWidth( aText );
- long nLabelHeight = rDev.GetTextHeight();
-
- // #i31600# if text is too long, cut and add ellipsis
- rText.second = nLabelWidth + 6 <= nWidth;
- if( !rText.second )
- {
- xub_StrLen nMinLen = 0;
- xub_StrLen nMaxLen = aText.Len();
- bool bFits = false;
- do
- {
- xub_StrLen nCurrLen = (nMinLen + nMaxLen) / 2;
- aText = String( rText.first, 0, nCurrLen ).AppendAscii( "..." );
- nLabelWidth = rDev.GetTextWidth( aText );
- bFits = nLabelWidth + 6 <= nWidth;
- (bFits ? nMinLen : nMaxLen) = nCurrLen;
- }
- while( !bFits || (nMinLen + 1 < nMaxLen) );
+void ScPivotFieldWindow::ReadDataLabels( const ScDPLabelDataVector& rLabels )
+{
+ maFields.clear();
+ maFields.reserve( rLabels.size() );
+ for( ScDPLabelDataVector::const_iterator aIt = rLabels.begin(), aEnd = rLabels.end(); aIt != aEnd; ++aIt )
+ {
+ ScPivotWindowField aField( *aIt );
+ if( aField.maFieldName.getLength() > 0 )
+ maFields.push_back( aField );
}
- Point aLabelPos( (nWidth - nLabelWidth) / 2, ::std::max< long >( (nHeight - nLabelHeight) / 2, 3 ) );
-
- aVirDev.SetOutputSizePixel( aDevSize );
- aVirDev.SetFont( rDev.GetFont() );
- DecorationView aDecoView( &aVirDev );
- aDecoView.DrawButton( Rectangle( Point( 0, 0 ), aDevSize ), bFocus ? BUTTON_DRAW_DEFAULT : 0 );
- aVirDev.SetTextColor( aTextColor );
- aVirDev.DrawText( aLabelPos, aText );
- rDev.DrawBitmap( rRect.TopLeft(), aVirDev.GetBitmap( Point( 0, 0 ), aDevSize ) );
+ Invalidate();
}
-void ScDPFieldWindow::Redraw()
+void ScPivotFieldWindow::ReadPivotFields( const ScPivotFieldVector& rPivotFields )
{
- VirtualDevice aVirDev;
- // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
- aVirDev.EnableRTL( IsRTLEnabled() );
- aVirDev.SetMapMode( MAP_PIXEL );
-
- Point aPos0;
- Size aSize( GetSizePixel() );
- Font aFont( GetFont() ); // Font vom Window
- aFont.SetTransparent( sal_True );
- aVirDev.SetFont( aFont );
- aVirDev.SetOutputSizePixel( aSize );
-
- DrawBackground( aVirDev );
-
- if( !aFieldArr.empty() && (nFieldSelected >= aFieldArr.size()) )
- nFieldSelected = aFieldArr.size() - 1;
- Rectangle aFieldRect( aPos0, GetFieldSize() );
- for( size_t nIx = 0; nIx < aFieldArr.size(); ++nIx )
+ maFields.clear();
+ maFields.reserve( rPivotFields.size() );
+ for( ScPivotFieldVector::const_iterator aIt = rPivotFields.begin(), aEnd = rPivotFields.end(); aIt != aEnd; ++aIt )
{
- aFieldRect.SetPos( GetFieldPosition( nIx ) );
- bool bFocus = HasFocus() && (nIx == nFieldSelected);
- DrawField( aVirDev, aFieldRect, aFieldArr[ nIx ], bFocus );
+ ScPivotWindowField aField( *mpDialog, *aIt, meFieldType == PIVOTFIELDTYPE_DATA );
+ if( aField.maFieldName.getLength() > 0 )
+ maFields.push_back( aField );
}
- DrawBitmap( aPos0, aVirDev.GetBitmap( aPos0, aSize ) );
+ Invalidate();
+}
- if( HasFocus() && (nFieldSelected < aFieldArr.size()) )
+void ScPivotFieldWindow::WriteFieldNames( ScDPNameVec& rFieldNames ) const
+{
+ rFieldNames.clear();
+ rFieldNames.reserve( maFields.size() );
+ // do not use the names stored in maFields, but generate plain display names from label data
+ for( ScPivotWindowFieldVector::const_iterator aIt = maFields.begin(), aEnd = maFields.end(); aIt != aEnd; ++aIt )
{
- long nFieldWidth = aFieldRect.GetWidth();
- long nSelectionWidth = Min( GetTextWidth( aFieldArr[ nFieldSelected ].first ) + 4, nFieldWidth - 6 );
- Rectangle aSelection(
- GetFieldPosition( nFieldSelected ) + Point( (nFieldWidth - nSelectionWidth) / 2, 3 ),
- Size( nSelectionWidth, aFieldRect.GetHeight() - 6 ) );
- InvertTracking( aSelection, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ if( ScDPLabelData* pLabelData = mpDialog->GetLabelData( aIt->maFuncData.mnCol ) )
+ {
+ OUString aDisplayName = pLabelData->getDisplayName();
+ if( aDisplayName.getLength() > 0 )
+ rFieldNames.push_back( aDisplayName );
+ }
}
-
- UpdateStyle();
}
-void ScDPFieldWindow::UpdateStyle()
+void ScPivotFieldWindow::WritePivotFields( ScPivotFieldVector& rPivotFields ) const
{
- WinBits nMask = ~(WB_TABSTOP | WB_NOTABSTOP);
- SetStyle( (GetStyle() & nMask) | (IsEmpty() ? WB_NOTABSTOP : WB_TABSTOP) );
+ rPivotFields.resize( maFields.size() );
+ ScPivotFieldVector::iterator aOutIt = rPivotFields.begin();
+ for( ScPivotWindowFieldVector::const_iterator aIt = maFields.begin(), aEnd = maFields.end(); aIt != aEnd; ++aIt, ++aOutIt )
+ {
+ aOutIt->nCol = aIt->maFuncData.mnCol;
+ aOutIt->nFuncMask = aIt->maFuncData.mnFuncMask;
+ aOutIt->maFieldRef = aIt->maFuncData.maFieldRef;
+ }
}
-//-------------------------------------------------------------------
-
-bool ScDPFieldWindow::IsValidIndex( size_t nIndex ) const
+OUString ScPivotFieldWindow::GetDescription() const
{
- return nIndex < nFieldSize;
+ switch( meFieldType )
+ {
+ case PIVOTFIELDTYPE_COL: return String( ScResId( STR_ACC_DATAPILOT_COL_DESCR ) );
+ case PIVOTFIELDTYPE_ROW: return String( ScResId( STR_ACC_DATAPILOT_ROW_DESCR ) );
+ case PIVOTFIELDTYPE_DATA: return String( ScResId( STR_ACC_DATAPILOT_DATA_DESCR ) );
+ case PIVOTFIELDTYPE_SELECT: return String( ScResId( STR_ACC_DATAPILOT_SEL_DESCR ) );
+ default:;
+ }
+ return OUString();
}
-bool ScDPFieldWindow::IsExistingIndex( size_t nIndex ) const
+OUString ScPivotFieldWindow::GetFieldText( size_t nFieldIndex ) const
{
- return nIndex < aFieldArr.size();
+ return (nFieldIndex < maFields.size()) ? maFields[ nFieldIndex ].maFieldName : OUString();
}
-bool ScDPFieldWindow::IsShortenedText( size_t nIndex ) const
+ScPivotFuncDataEntry ScPivotFieldWindow::FindFuncDataByCol( SCCOL nCol ) const
{
- return (nIndex < aFieldArr.size()) && !aFieldArr[ nIndex ].second;
+ for( ScPivotWindowFieldVector::const_iterator aIt = maFields.begin(), aEnd = maFields.end(); aIt != aEnd; ++aIt )
+ if( aIt->maFuncData.mnCol == nCol )
+ return ScPivotFuncDataEntry( &aIt->maFuncData, aIt - maFields.begin() );
+ return ScPivotFuncDataEntry( 0, PIVOTFIELD_INVALID );
}
-size_t ScDPFieldWindow::CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const
+Point ScPivotFieldWindow::GetFieldPosition( size_t nFieldIndex ) const
{
- size_t nNewField = nFieldSelected;
- switch( eType )
- {
- case TYPE_PAGE:
- nNewField += static_cast<SCsCOLROW>(nDX) + nDY * MAX_PAGEFIELDS / 2;
- break;
- case TYPE_COL:
- nNewField += static_cast<SCsCOLROW>(nDX) + nDY * MAX_FIELDS / 2;
- break;
- case TYPE_ROW:
- case TYPE_DATA:
- nNewField += nDY;
- break;
- case TYPE_SELECT:
- nNewField += static_cast<SCsCOLROW>(nDX) * LINE_SIZE + nDY;
- break;
- }
-
- return IsExistingIndex( nNewField ) ? nNewField : nFieldSelected;
+ long nRelIndex = static_cast< long >( nFieldIndex ) - mnFirstVisIndex;
+ long nCol = static_cast< long >( mbVertical ? (nRelIndex / mnRowCount) : (nRelIndex % mnColCount) );
+ long nRow = static_cast< long >( mbVertical ? (nRelIndex % mnRowCount) : (nRelIndex / mnColCount) );
+ return Point( nCol * (maFieldSize.Width() + maSpaceSize.Width()), nRow * (maFieldSize.Height() + maSpaceSize.Height()) );
}
-void ScDPFieldWindow::SetSelection( size_t nIndex )
+size_t ScPivotFieldWindow::GetFieldIndex( const Point& rWindowPos ) const
{
- if( !aFieldArr.empty() )
+ if( (rWindowPos.X() >= 0) && (rWindowPos.Y() >= 0) )
{
- if( nFieldSelected >= aFieldArr.size() )
- nFieldSelected = aFieldArr.size() - 1;
- if( nFieldSelected != nIndex )
+ long nGridWidth = maFieldSize.Width() + maSpaceSize.Width();
+ long nGridHeight = maFieldSize.Height() + maSpaceSize.Height();
+ size_t nCol = static_cast< size_t >( rWindowPos.X() / nGridWidth );
+ size_t nRow = static_cast< size_t >( rWindowPos.Y() / nGridHeight );
+ if( (nCol < mnColCount) && (nRow < mnRowCount) )
{
- sal_Int32 nOldSelected(nFieldSelected);
- nFieldSelected = nIndex;
- Redraw();
-
- if (pAccessible && HasFocus())
+ long nColOffset = rWindowPos.X() % nGridWidth;
+ long nRowOffset = rWindowPos.Y() % nGridHeight;
+ // check that passed position is not in the space between the fields
+ if( (nColOffset < maFieldSize.Width()) && (nRowOffset < maFieldSize.Height()) )
{
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (xTempAcc.is())
- pAccessible->FieldFocusChange(nOldSelected, nFieldSelected);
- else
- pAccessible = NULL;
+ size_t nFieldIndex = mnFirstVisIndex + (mbVertical ? (nCol * mnRowCount + nRow) : (nRow * mnColCount + nCol));
+ return (nFieldIndex < maFields.size()) ? nFieldIndex : PIVOTFIELD_INVALID;
}
}
}
+ return PIVOTFIELD_INVALID;
}
-void ScDPFieldWindow::SetSelectionHome()
+size_t ScPivotFieldWindow::GetDropIndex( const Point& rWindowPos ) const
{
- if( !aFieldArr.empty() )
+ if( (rWindowPos.X() >= 0) && (rWindowPos.Y() >= 0) )
{
- if( eType == TYPE_SELECT )
- pDlg->NotifyMoveSlider( KEY_HOME );
- SetSelection( 0 );
+ long nGridWidth = maFieldSize.Width() + maSpaceSize.Width();
+ long nGridHeight = maFieldSize.Height() + maSpaceSize.Height();
+ size_t nCol = static_cast< size_t >( rWindowPos.X() / nGridWidth );
+ size_t nRow = static_cast< size_t >( rWindowPos.Y() / nGridHeight );
+ if( (nCol < mnColCount) && (nRow < mnRowCount) )
+ {
+ size_t nFieldIndex = mnFirstVisIndex + (mbVertical ? (nCol * mnRowCount + nRow) : (nRow * mnColCount + nCol));
+ long nColOffset = rWindowPos.X() % nGridWidth;
+ long nRowOffset = rWindowPos.Y() % nGridHeight;
+ // take next field, if position is in right/lower third
+ if( (mnColCount == 1) ? (nRowOffset * 3 > nGridHeight * 2) : (nColOffset * 3 > nGridWidth * 2) )
+ ++nFieldIndex;
+ return ::std::min( nFieldIndex, maFields.size() );
+ }
}
+ return maFields.size();
}
-void ScDPFieldWindow::SetSelectionEnd()
+void ScPivotFieldWindow::GrabFocusAndSelect( size_t nSelectIndex )
{
- if( !aFieldArr.empty() )
- {
- if( eType == TYPE_SELECT )
- pDlg->NotifyMoveSlider( KEY_END );
- SetSelection( aFieldArr.size() - 1 );
- }
+ if( !HasFocus() ) GrabFocus();
+ MoveSelection( nSelectIndex );
}
-void ScDPFieldWindow::MoveSelection( sal_uInt16 nKeyCode, SCsCOL nDX, SCsROW nDY )
+void ScPivotFieldWindow::SelectNextField()
{
- size_t nNewIndex = CalcNewFieldIndex( nDX, nDY );
- if( (eType == TYPE_SELECT) && (nNewIndex == nFieldSelected) )
+ MoveSelection( NEXT_FIELD );
+}
+
+void ScPivotFieldWindow::InsertField( size_t nInsertIndex, const ScPivotFuncData& rFuncData )
+{
+ if( (meFieldType != PIVOTFIELDTYPE_SELECT) && (nInsertIndex <= maFields.size()) )
{
- if( pDlg->NotifyMoveSlider( nKeyCode ) )
+ size_t nFieldIndex = FindFuncDataByCol( rFuncData.mnCol ).second;
+ if( nFieldIndex < maFields.size() )
+ {
+ // field exists already in this window, move it to the specified position
+ MoveField( nFieldIndex, nInsertIndex );
+ }
+ else
{
- switch( nKeyCode )
+ // insert the field into the vector and notify accessibility object
+ ScPivotWindowField aField( *mpDialog, rFuncData, meFieldType == PIVOTFIELDTYPE_DATA );
+ if( aField.maFieldName.getLength() > 0 )
{
- case KEY_UP: nNewIndex += (LINE_SIZE - 1); break;
- case KEY_DOWN: nNewIndex -= (LINE_SIZE - 1); break;
+ InsertFieldUnchecked( nInsertIndex, aField );
+ // adjust selection and scroll position
+ MoveSelection( nInsertIndex );
+ Invalidate();
}
}
}
- SetSelection( nNewIndex );
}
-void ScDPFieldWindow::ModifySelectionOffset( long nOffsetDiff )
+bool ScPivotFieldWindow::RemoveField( size_t nRemoveIndex )
{
- nFieldSelected -= nOffsetDiff;
- Redraw();
+ if( (meFieldType != PIVOTFIELDTYPE_SELECT) && (nRemoveIndex < maFields.size()) )
+ {
+ // remove the field from the vector and notify accessibility object
+ RemoveFieldUnchecked( nRemoveIndex );
+ // adjust selection and scroll position, if last field is removed
+ if( !maFields.empty() )
+ MoveSelection( (mnSelectIndex < maFields.size()) ? mnSelectIndex : (maFields.size() - 1) );
+ Invalidate();
+ return true;
+ }
+ return false;
}
-void ScDPFieldWindow::SelectNext()
+bool ScPivotFieldWindow::MoveField( size_t nFieldIndex, size_t nInsertIndex )
{
- if( eType == TYPE_SELECT )
- MoveSelection( KEY_DOWN, 0, 1 );
+ /* If field is moved behind current position, insertion index needs to be
+ adjusted, because the field is first removed from the vector. This is
+ done before nFieldIndex and nInsertIndex are checked for equality, to
+ catch the cases "move before ourselves" and "move bedind ourselves"
+ which are both no-ops. */
+ if( nFieldIndex < nInsertIndex )
+ --nInsertIndex;
+
+ if( (meFieldType != PIVOTFIELDTYPE_SELECT) && (nFieldIndex != nInsertIndex) && (nFieldIndex < maFields.size()) && (nInsertIndex < maFields.size()) )
+ {
+ // move the field in the vector and notify accessibility object
+ ScPivotWindowField aField = maFields[ nFieldIndex ];
+ RemoveFieldUnchecked( nFieldIndex );
+ InsertFieldUnchecked( nInsertIndex, aField );
+ // adjust selection and scroll position
+ MoveSelection( nInsertIndex );
+ Invalidate();
+ return true;
+ }
+ return false;
}
-void ScDPFieldWindow::GrabFocusWithSel( size_t nIndex )
+const ScPivotFuncData* ScPivotFieldWindow::GetSelectedFuncData() const
{
- SetSelection( nIndex );
- if( !HasFocus() )
- GrabFocus();
+ return (mnSelectIndex < maFields.size()) ? &maFields[ mnSelectIndex ].maFuncData : 0;
}
-void ScDPFieldWindow::MoveField( size_t nDestIndex )
+void ScPivotFieldWindow::ModifySelectedField( const ScPivotFuncData& rFuncData )
{
- if( nDestIndex != nFieldSelected )
+ if( mnSelectIndex < maFields.size() )
{
- // "recycle" existing functionality
- pDlg->NotifyMouseButtonDown( eType, nFieldSelected );
- pDlg->NotifyMouseButtonUp( OutputToScreenPixel( GetFieldPosition( nDestIndex ) ) );
+ maFields[ mnSelectIndex ].maFuncData = rFuncData;
+ maFields[ mnSelectIndex ].InitFieldName( *mpDialog, meFieldType == PIVOTFIELDTYPE_DATA );
+ Invalidate();
}
}
-void ScDPFieldWindow::MoveFieldRel( SCsCOL nDX, SCsROW nDY )
+bool ScPivotFieldWindow::RemoveSelectedField()
{
- MoveField( CalcNewFieldIndex( nDX, nDY ) );
+ return RemoveField( mnSelectIndex );
}
-//-------------------------------------------------------------------
-
-void __EXPORT ScDPFieldWindow::Paint( const Rectangle& /* rRect */ )
+bool ScPivotFieldWindow::MoveSelectedField( size_t nInsertIndex )
{
- // #124828# hiding the caption is now done from StateChanged
- Redraw();
+ return MoveField( mnSelectIndex, nInsertIndex );
}
-void ScDPFieldWindow::UseMnemonic()
+void ScPivotFieldWindow::NotifyStartTracking()
{
- // Now the FixedText has its mnemonic char. Grab the text and hide the
- // FixedText to be able to handle tabstop and mnemonics separately.
- if( pFtCaption )
- {
- SetText( pFtCaption->GetText() );
- pFtCaption->Hide();
- }
-
- // after reading the mnemonics, tab stop style bits can be updated
- UpdateStyle();
+ // rescue old scrolling index, to be able to restore it when tracking is cancelled
+ mnOldFirstVisIndex = mnFirstVisIndex;
}
-void __EXPORT ScDPFieldWindow::DataChanged( const DataChangedEvent& rDCEvt )
+void ScPivotFieldWindow::NotifyTracking( const Point& rWindowPos )
{
- if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ size_t nFieldIndex = GetDropIndex( rWindowPos );
+
+ // insertion index changed: draw new cursor and exit
+ if( nFieldIndex != mnInsCursorIndex )
{
- GetStyleSettings();
- Redraw();
+ mnInsCursorIndex = nFieldIndex;
+ mnAutoScrollDelay = INITIAL_TRACKING_DELAY;
+ Invalidate();
+ return;
}
- Control::DataChanged( rDCEvt );
-}
-void __EXPORT ScDPFieldWindow::MouseButtonDown( const MouseEvent& rMEvt )
-{
- if( rMEvt.IsLeft() )
+ // insertion index unchanged: countdown for auto scrolling
+ if( mnAutoScrollDelay > 0 )
{
- size_t nIndex = 0;
- if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsExistingIndex( nIndex ) )
- {
- GrabFocusWithSel( nIndex );
+ --mnAutoScrollDelay;
+ return;
+ }
- if( rMEvt.GetClicks() == 1 )
- {
- PointerStyle ePtr = pDlg->NotifyMouseButtonDown( eType, nIndex );
- CaptureMouse();
- SetPointer( Pointer( ePtr ) );
- }
- else
- pDlg->NotifyDoubleClick( eType, nIndex );
- }
+ // check if tracking happens on first or last field
+ long nScrollDelta = 0;
+ if( (mnInsCursorIndex > 0) && (mnInsCursorIndex == mnFirstVisIndex) )
+ nScrollDelta = -static_cast< long >( mnLineSize );
+ else if( (mnInsCursorIndex < maFields.size()) && (mnInsCursorIndex == mnFirstVisIndex + mnPageSize) )
+ nScrollDelta = static_cast< long >( mnLineSize );
+ if( nScrollDelta != 0 )
+ {
+ // update mnInsCursorIndex, so it will be drawn at the same position after scrolling
+ mnInsCursorIndex += nScrollDelta;
+ mnFirstVisIndex += nScrollDelta;
+ // delay auto scroll by line size, to slow down scrolling in column/page windows
+ mnAutoScrollDelay = mnLineSize - 1;
+ Invalidate();
}
}
-void __EXPORT ScDPFieldWindow::MouseButtonUp( const MouseEvent& rMEvt )
+void ScPivotFieldWindow::NotifyEndTracking( ScPivotFieldEndTracking eEndType )
{
- if( rMEvt.IsLeft() )
+ if( eEndType != ENDTRACKING_DROP )
+ mnFirstVisIndex = mnOldFirstVisIndex;
+ if( eEndType != ENDTRACKING_SUSPEND )
{
- if( rMEvt.GetClicks() == 1 )
- {
- pDlg->NotifyMouseButtonUp( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
- SetPointer( Pointer( POINTER_ARROW ) );
- }
-
- if( IsMouseCaptured() )
- ReleaseMouse();
+ mnOldFirstVisIndex = PIVOTFIELD_INVALID;
+ mbIsTrackingSource = false;
}
+ mnInsCursorIndex = PIVOTFIELD_INVALID;
+ Invalidate();
}
-void __EXPORT ScDPFieldWindow::MouseMove( const MouseEvent& rMEvt )
+// protected ------------------------------------------------------------------
+
+void ScPivotFieldWindow::Paint( const Rectangle& /*rRect*/ )
{
- if( IsMouseCaptured() )
+ // prepare a virtual device for buffered painting
+ VirtualDevice aVirDev;
+ // #i97623# VirtualDevice is always LTR on construction while other windows derive direction from parent
+ aVirDev.EnableRTL( IsRTLEnabled() );
+ aVirDev.SetMapMode( MAP_PIXEL );
+ aVirDev.SetOutputSizePixel( GetSizePixel() );
+ Font aFont = GetFont();
+ aFont.SetTransparent( true );
+ aVirDev.SetFont( aFont );
+
+ // draw the background and all fields
+ DrawBackground( aVirDev );
+ for( size_t nFieldIndex = mnFirstVisIndex, nEndIndex = mnFirstVisIndex + mnPageSize; nFieldIndex < nEndIndex; ++nFieldIndex )
+ DrawField( aVirDev, nFieldIndex );
+ DrawInsertionCursor( aVirDev );
+ DrawBitmap( Point( 0, 0 ), aVirDev.GetBitmap( Point( 0, 0 ), GetSizePixel() ) );
+
+ // draw field text focus
+ if( HasFocus() && (mnSelectIndex < maFields.size()) && (mnFirstVisIndex <= mnSelectIndex) && (mnSelectIndex < mnFirstVisIndex + mnPageSize) )
{
- PointerStyle ePtr = pDlg->NotifyMouseMove( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
- SetPointer( Pointer( ePtr ) );
+ long nFieldWidth = maFieldSize.Width();
+ long nSelectionWidth = Min( GetTextWidth( maFields[ mnSelectIndex ].maFieldName ) + 4, nFieldWidth - 6 );
+ Rectangle aSelection(
+ GetFieldPosition( mnSelectIndex ) + Point( (nFieldWidth - nSelectionWidth) / 2, 3 ),
+ Size( nSelectionWidth, maFieldSize.Height() - 6 ) );
+ InvertTracking( aSelection, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
}
- size_t nIndex = 0;
- if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsShortenedText( nIndex ) )
+
+ // update scrollbar
+ size_t nFieldCount = maFields.size();
+ /* Already show the scrollbar if window is full but no fields are hidden
+ (yet). This gives the user the hint that it is now possible to add more
+ fields to the window. */
+ mrScrollBar.Show( nFieldCount >= mnPageSize );
+ mrScrollBar.Enable( nFieldCount > mnPageSize );
+ if( mrScrollBar.IsVisible() )
{
- Point aPos = OutputToScreenPixel( rMEvt.GetPosPixel() );
- Rectangle aRect( aPos, GetSizePixel() );
- String aHelpText = GetFieldText(nIndex);
- Help::ShowQuickHelp( this, aRect, aHelpText );
+ mrScrollBar.SetRange( Range( 0, static_cast< long >( (nFieldCount - 1) / mnLineSize + 1 ) ) );
+ mrScrollBar.SetThumbPos( static_cast< long >( mnFirstVisIndex / mnLineSize ) );
}
+
+ /* Exclude empty fields from tab chain, but do not disable them. They need
+ to be enabled because they still act as target for field movement via
+ keyboard shortcuts. */
+ WinBits nMask = ~(WB_TABSTOP | WB_NOTABSTOP);
+ SetStyle( (GetStyle() & nMask) | (IsEmpty() ? WB_NOTABSTOP : WB_TABSTOP) );
}
-void __EXPORT ScDPFieldWindow::KeyInput( const KeyEvent& rKEvt )
+void ScPivotFieldWindow::StateChanged( StateChangedType nStateChange )
{
- const KeyCode& rKeyCode = rKEvt.GetKeyCode();
- sal_uInt16 nCode = rKeyCode.GetCode();
- sal_Bool bKeyEvaluated = sal_False;
+ Control::StateChanged( nStateChange );
- if( rKeyCode.IsMod1() && (eType != TYPE_SELECT) )
- {
- bKeyEvaluated = sal_True;
- switch( nCode )
- {
- case KEY_UP: MoveFieldRel( 0, -1 ); break;
- case KEY_DOWN: MoveFieldRel( 0, 1 ); break;
- case KEY_LEFT: MoveFieldRel( -1, 0 ); break;
- case KEY_RIGHT: MoveFieldRel( 1, 0 ); break;
- case KEY_HOME: MoveField( 0 ); break;
- case KEY_END: MoveField( aFieldArr.size() - 1 ); break;
- default: bKeyEvaluated = sal_False;
- }
- }
- else
+ if( nStateChange == STATE_CHANGE_INITSHOW )
{
- bKeyEvaluated = sal_True;
- switch( nCode )
+ /* After the fixed text associated to this control has received its
+ unique mnemonic from VCL dialog initialization code, put this text
+ into the field windows.
+ #124828# Hiding the FixedTexts and clearing the tab stop style bits
+ has to be done after assigning the mnemonics, but Paint() is too
+ late, because the test tool may send key events to the dialog when
+ it isn't visible. Mnemonics are assigned in Dialog::StateChanged()
+ for STATE_CHANGE_INITSHOW, so this can be done immediately
+ afterwards. */
+ if( mpFtCaption )
{
- case KEY_UP: MoveSelection( nCode, 0, -1 ); break;
- case KEY_DOWN: MoveSelection( nCode, 0, 1 ); break;
- case KEY_LEFT: MoveSelection( nCode, -1, 0 ); break;
- case KEY_RIGHT: MoveSelection( nCode, 1, 0 ); break;
- case KEY_HOME: SetSelectionHome(); break;
- case KEY_END: SetSelectionEnd(); break;
- case KEY_DELETE:
- pDlg->NotifyRemoveField( eType, nFieldSelected ); break;
- default: bKeyEvaluated = sal_False;
+ SetText( mpFtCaption->GetText() );
+ mpFtCaption->Hide();
}
}
-
- if( !bKeyEvaluated )
- Control::KeyInput( rKEvt );
}
-void __EXPORT ScDPFieldWindow::GetFocus()
+void ScPivotFieldWindow::DataChanged( const DataChangedEvent& rDCEvt )
{
- Control::GetFocus();
- Redraw();
- if( GetGetFocusFlags() & GETFOCUS_MNEMONIC ) // move field on shortcut
- pDlg->NotifyMoveField( eType );
- else // else change focus
- pDlg->NotifyFieldFocus( eType, sal_True );
-
- if (pAccessible)
- {
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (xTempAcc.is())
- pAccessible->GotFocus();
- else
- pAccessible = NULL;
- }
+ Control::DataChanged( rDCEvt );
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ Invalidate();
}
-void __EXPORT ScDPFieldWindow::LoseFocus()
+void ScPivotFieldWindow::KeyInput( const KeyEvent& rKEvt )
{
- Control::LoseFocus();
- Redraw();
- pDlg->NotifyFieldFocus( eType, sal_False );
+ bool bKeyEvaluated = false;
- if (pAccessible)
+ if( !maFields.empty() )
{
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (xTempAcc.is())
- pAccessible->LostFocus();
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ sal_uInt16 nCode = rKeyCode.GetCode();
+
+ // do not move fields in selection window
+ if( rKeyCode.IsMod1() && (meFieldType != PIVOTFIELDTYPE_SELECT) )
+ {
+ bKeyEvaluated = true;
+ switch( nCode )
+ {
+ case KEY_UP: MoveSelectedField( mbVertical ? PREV_FIELD : PREV_LINE ); break;
+ case KEY_DOWN: MoveSelectedField( mbVertical ? NEXT_FIELD : NEXT_LINE ); break;
+ case KEY_LEFT: MoveSelectedField( mbVertical ? PREV_LINE : PREV_FIELD ); break;
+ case KEY_RIGHT: MoveSelectedField( mbVertical ? NEXT_LINE : NEXT_FIELD ); break;
+ case KEY_HOME: MoveSelectedField( FIRST_FIELD ); break;
+ case KEY_END: MoveSelectedField( LAST_FIELD ); break;
+ default: bKeyEvaluated = false;
+ }
+ }
else
- pAccessible = NULL;
+ {
+ bKeyEvaluated = true;
+ switch( nCode )
+ {
+ case KEY_UP: MoveSelection( mbVertical ? PREV_FIELD : PREV_LINE ); break;
+ case KEY_DOWN: MoveSelection( mbVertical ? NEXT_FIELD : NEXT_LINE ); break;
+ case KEY_LEFT: MoveSelection( mbVertical ? PREV_LINE : PREV_FIELD ); break;
+ case KEY_RIGHT: MoveSelection( mbVertical ? NEXT_LINE : NEXT_FIELD ); break;
+ case KEY_PAGEUP: MoveSelection( PREV_PAGE ); break;
+ case KEY_PAGEDOWN: MoveSelection( NEXT_PAGE ); break;
+ case KEY_HOME: MoveSelection( FIRST_FIELD ); break;
+ case KEY_END: MoveSelection( LAST_FIELD ); break;
+ // delete field per DEL key - dialog needs to change focus if window becomes empty
+ case KEY_DELETE: RemoveSelectedField(); mpDialog->NotifyFieldRemoved( *this ); break;
+ default: bKeyEvaluated = false;
+ }
+ }
}
-}
-//-------------------------------------------------------------------
+ if( !bKeyEvaluated )
+ Control::KeyInput( rKEvt );
+}
-void ScDPFieldWindow::AddField( const String& rText, size_t nNewIndex )
+void ScPivotFieldWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
- DBG_ASSERT( nNewIndex == aFieldArr.size(), "ScDPFieldWindow::AddField - invalid index" );
- if( IsValidIndex( nNewIndex ) )
+ if( rMEvt.IsLeft() )
{
- aFieldArr.push_back( FieldString( rText, true ) );
- if (pAccessible)
+ size_t nNewSelectIndex = GetFieldIndex( rMEvt.GetPosPixel() );
+ if( nNewSelectIndex < maFields.size() )
{
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (xTempAcc.is())
- pAccessible->AddField(nNewIndex);
+ // grabbing after GetFieldIndex() will prevent to focus empty window
+ GrabFocusAndSelect( nNewSelectIndex );
+ if( rMEvt.GetClicks() == 1 )
+ {
+ // one click: start tracking
+ mbIsTrackingSource = true;
+ mnOldFirstVisIndex = mnFirstVisIndex;
+ mpDialog->NotifyStartTracking( *this );
+ }
else
- pAccessible = NULL;
+ {
+ // two clicks: open field options dialog
+ mpDialog->NotifyDoubleClick( *this );
+ }
}
}
}
-void ScDPFieldWindow::DelField( size_t nDelIndex )
+void ScPivotFieldWindow::RequestHelp( const HelpEvent& rHEvt )
{
- if( IsExistingIndex( nDelIndex ) )
+ if( (rHEvt.GetMode() & HELPMODE_QUICK) != 0 )
{
- if (pAccessible) // before decrement fieldcount
+ // show a tooltip with full field name, if field text is clipped
+ size_t nFieldIndex = GetFieldIndex( rHEvt.GetMousePosPixel() - GetPosPixel() );
+ if( (nFieldIndex < maFields.size()) && maFields[ nFieldIndex ].mbClipped )
{
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (xTempAcc.is())
- pAccessible->RemoveField(nDelIndex);
- else
- pAccessible = NULL;
+ Rectangle aRect( rHEvt.GetMousePosPixel(), GetSizePixel() );
+ Help::ShowQuickHelp( this, aRect, maFields[ nFieldIndex ].maFieldName );
+ return;
}
- aFieldArr.erase( aFieldArr.begin() + nDelIndex );
- Redraw();
}
+ Control::RequestHelp( rHEvt );
}
-void ScDPFieldWindow::ClearFields()
+void ScPivotFieldWindow::GetFocus()
{
- if( eType == TYPE_SELECT || eType == TYPE_PAGE || eType == TYPE_COL || eType == TYPE_ROW || eType == TYPE_DATA)
- {
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (!xTempAcc.is() && pAccessible)
- pAccessible = NULL;
- if (pAccessible)
- for( size_t nIdx = aFieldArr.size(); nIdx > 0; --nIdx )
- pAccessible->RemoveField( nIdx - 1 );
+ Control::GetFocus();
+ Invalidate();
+ ::rtl::Reference< ScAccessibleDataPilotControl > xAcc = GetAccessibleControl();
+ if( xAcc.is() )
+ xAcc->GotFocus();
+}
- aFieldArr.clear();
- }
+void ScPivotFieldWindow::LoseFocus()
+{
+ Control::LoseFocus();
+ Invalidate();
+ ::rtl::Reference< ScAccessibleDataPilotControl > xAcc = GetAccessibleControl();
+ if( xAcc.is() )
+ xAcc->LostFocus();
+}
+
+uno::Reference< accessibility::XAccessible > ScPivotFieldWindow::CreateAccessible()
+{
+ mpAccessible = new ScAccessibleDataPilotControl( GetAccessibleParentWindow()->GetAccessible(), this );
+ uno::Reference< accessibility::XAccessible > xReturn( mpAccessible );
+ mpAccessible->Init();
+ mxAccessible = xReturn;
+ return xReturn;
+}
+
+// private --------------------------------------------------------------------
+
+size_t ScPivotFieldWindow::RecalcVisibleIndex( size_t nSelectIndex ) const
+{
+ // calculate a scrolling offset that shows the selected field
+ size_t nNewFirstVisIndex = mnFirstVisIndex;
+ if( nSelectIndex < nNewFirstVisIndex )
+ nNewFirstVisIndex = static_cast< size_t >( (nSelectIndex / mnLineSize) * mnLineSize );
+ else if( nSelectIndex >= nNewFirstVisIndex + mnPageSize )
+ nNewFirstVisIndex = static_cast< size_t >( (nSelectIndex / mnLineSize + 1) * mnLineSize ) - mnPageSize;
+ // check if there are complete empty lines in the bottom/right
+ size_t nMaxFirstVisIndex = (maFields.size() <= mnPageSize) ? 0 : (((maFields.size() - 1) / mnLineSize + 1) * mnLineSize - mnPageSize);
+ return ::std::min( nNewFirstVisIndex, nMaxFirstVisIndex );
}
-void ScDPFieldWindow::SetFieldText( const String& rText, size_t nIndex )
+void ScPivotFieldWindow::SetSelectionUnchecked( size_t nSelectIndex, size_t nFirstVisIndex )
{
- if( IsExistingIndex( nIndex ) )
+ if( !maFields.empty() && (nSelectIndex < maFields.size()) )
{
- aFieldArr[ nIndex ] = FieldString( rText, true );
- Redraw();
+ bool bScrollPosChanged = mnFirstVisIndex != nFirstVisIndex;
+ bool bSelectionChanged = mnSelectIndex != nSelectIndex;
- if (pAccessible)
+ sal_Int32 nOldSelected = static_cast< sal_Int32 >( mnSelectIndex );
+ mnFirstVisIndex = nFirstVisIndex;
+ mnSelectIndex = nSelectIndex;
+
+ if( bScrollPosChanged || bSelectionChanged )
+ Invalidate();
+
+ // TODO: accessibility action for changed scrolling position?
+
+ // notify accessibility object about changed selection
+ if( bSelectionChanged && HasFocus() )
{
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (xTempAcc.is())
- pAccessible->FieldNameChange(nIndex);
- else
- pAccessible = NULL;
+ ::rtl::Reference< ScAccessibleDataPilotControl > xAcc = GetAccessibleControl();
+ if( xAcc.is() )
+ xAcc->FieldFocusChange( nOldSelected, static_cast< sal_Int32 >( mnSelectIndex ) );
}
}
}
-const String& ScDPFieldWindow::GetFieldText( size_t nIndex ) const
+void ScPivotFieldWindow::MoveSelection( size_t nSelectIndex )
{
- if( IsExistingIndex( nIndex ) )
- return aFieldArr[ nIndex ].first;
- return EMPTY_STRING;
+ if( nSelectIndex < maFields.size() )
+ SetSelectionUnchecked( nSelectIndex, RecalcVisibleIndex( nSelectIndex ) );
}
-//-------------------------------------------------------------------
-
-bool ScDPFieldWindow::AddField( const String& rText, const Point& rPos, size_t& rnIndex )
+void ScPivotFieldWindow::MoveSelection( MoveType eMoveType )
{
- if ( aFieldArr.size() == nFieldSize )
- return sal_False;
+ if( maFields.empty() )
+ return;
- size_t nNewIndex = 0;
- if( GetFieldIndex( rPos, nNewIndex ) )
+ size_t nLastIndex = maFields.size() - 1;
+ size_t nNewSelectIndex = mnSelectIndex;
+ switch( eMoveType )
{
- if( nNewIndex > aFieldArr.size() )
- nNewIndex = aFieldArr.size();
-
- aFieldArr.insert( aFieldArr.begin() + nNewIndex, FieldString( rText, true ) );
- nFieldSelected = nNewIndex;
- Redraw();
- rnIndex = nNewIndex;
+ case PREV_FIELD:
+ nNewSelectIndex = (nNewSelectIndex > 0) ? (nNewSelectIndex - 1) : 0;
+ break;
+ case NEXT_FIELD:
+ nNewSelectIndex = (nNewSelectIndex < nLastIndex) ? (nNewSelectIndex + 1) : nLastIndex;
+ break;
+ case PREV_LINE:
+ nNewSelectIndex = (nNewSelectIndex > mnLineSize) ? (nNewSelectIndex - mnLineSize) : 0;
+ break;
+ case NEXT_LINE:
+ nNewSelectIndex = (nNewSelectIndex + mnLineSize < nLastIndex) ? (nNewSelectIndex + mnLineSize) : nLastIndex;
+ break;
+ case PREV_PAGE:
+ nNewSelectIndex = (nNewSelectIndex > mnPageSize) ? (nNewSelectIndex - mnPageSize) : 0;
+ break;
+ case NEXT_PAGE:
+ nNewSelectIndex = (nNewSelectIndex + mnPageSize < nLastIndex) ? (nNewSelectIndex + mnPageSize) : nLastIndex;
+ break;
+ case FIRST_FIELD:
+ nNewSelectIndex = 0;
+ break;
+ case LAST_FIELD:
+ nNewSelectIndex = nLastIndex;
+ break;
+ }
- if (pAccessible)
- {
- com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
- if (xTempAcc.is())
- pAccessible->AddField(nNewIndex);
- else
- pAccessible = NULL;
- }
+ // SetSelectionUnchecked() redraws the control and updates the scrollbar
+ SetSelectionUnchecked( nNewSelectIndex, RecalcVisibleIndex( nNewSelectIndex ) );
+}
- return true;
+void ScPivotFieldWindow::MoveSelectedField( MoveType eMoveType )
+{
+ if( mnSelectIndex < maFields.size() )
+ {
+ // find position to insert the field by changing the selection first
+ size_t nOldSelectIndex = mnSelectIndex;
+ MoveSelection( eMoveType );
+ MoveField( nOldSelectIndex, (nOldSelectIndex < mnSelectIndex) ? (mnSelectIndex + 1) : mnSelectIndex );
}
+}
- return false;
+void ScPivotFieldWindow::InsertFieldUnchecked( size_t nInsertIndex, const ScPivotWindowField& rField )
+{
+ maFields.insert( maFields.begin() + nInsertIndex, rField );
+ ::rtl::Reference< ScAccessibleDataPilotControl > xAcc = GetAccessibleControl();
+ if( xAcc.is() )
+ xAcc->AddField( static_cast< sal_Int32 >( nInsertIndex ) );
+}
+
+void ScPivotFieldWindow::RemoveFieldUnchecked( size_t nRemoveIndex )
+{
+ ::rtl::Reference< ScAccessibleDataPilotControl > xAcc = GetAccessibleControl();
+ if( xAcc.is() )
+ xAcc->RemoveField( static_cast< sal_Int32 >( nRemoveIndex ) );
+ maFields.erase( maFields.begin() + nRemoveIndex );
}
-void ScDPFieldWindow::GetExistingIndex( const Point& rPos, size_t& rnIndex )
+void ScPivotFieldWindow::DrawBackground( OutputDevice& rDev )
{
- if( !aFieldArr.empty() && (eType != TYPE_SELECT) && GetFieldIndex( rPos, rnIndex ) )
+ Size aDevSize = rDev.GetOutputSizePixel();
+ const StyleSettings& rStyleSett = GetSettings().GetStyleSettings();
+
+ if( meFieldType == PIVOTFIELDTYPE_SELECT )
{
- if( rnIndex >= aFieldArr.size() )
- rnIndex = aFieldArr.size() - 1;
+ rDev.SetLineColor();
+ rDev.SetFillColor( rStyleSett.GetFaceColor() );
+ rDev.DrawRect( Rectangle( Point( 0, 0 ), aDevSize ) );
}
else
- rnIndex = 0;
+ {
+ rDev.SetLineColor( rStyleSett.GetWindowTextColor() );
+ rDev.SetFillColor( rStyleSett.GetWindowColor() );
+ rDev.DrawRect( Rectangle( Point( 0, 0 ), aDevSize ) );
+
+ /* Draw the caption text. This needs some special handling, because we
+ support hard line breaks here. This part will draw each line of the
+ text for itself. */
+ rDev.SetTextColor( rStyleSett.GetWindowTextColor() );
+ xub_StrLen nTokenCnt = GetText().GetTokenCount( '\n' );
+ long nY = (aDevSize.Height() - nTokenCnt * rDev.GetTextHeight()) / 2;
+ for( xub_StrLen nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken )
+ {
+ String aLine = GetText().GetToken( 0, '\n', nStringIx );
+ Point aLinePos( (aDevSize.Width() - rDev.GetCtrlTextWidth( aLine )) / 2, nY );
+ rDev.DrawCtrlText( aLinePos, aLine );
+ nY += rDev.GetTextHeight();
+ }
+ }
}
-String ScDPFieldWindow::GetDescription() const
+void ScPivotFieldWindow::DrawField( OutputDevice& rDev, size_t nFieldIndex )
{
- String sDescription;
- switch( eType )
+ if( (nFieldIndex < maFields.size()) && (mnFirstVisIndex <= nFieldIndex) && (nFieldIndex < mnFirstVisIndex + mnPageSize) )
{
- case TYPE_COL:
- sDescription = ScResId(STR_ACC_DATAPILOT_COL_DESCR);
- break;
- case TYPE_ROW:
- sDescription = ScResId(STR_ACC_DATAPILOT_ROW_DESCR);
- break;
- case TYPE_DATA:
- sDescription = ScResId(STR_ACC_DATAPILOT_DATA_DESCR);
- break;
- case TYPE_SELECT:
- sDescription = ScResId(STR_ACC_DATAPILOT_SEL_DESCR);
- break;
- default:
+ // draw the button
+ Point aFieldPos = GetFieldPosition( nFieldIndex );
+ bool bFocus = HasFocus() && (nFieldIndex == mnSelectIndex);
+ DecorationView aDecoView( &rDev );
+ aDecoView.DrawButton( Rectangle( aFieldPos, maFieldSize ), bFocus ? BUTTON_DRAW_DEFAULT : 0 );
+
+ // #i31600# if text is too long, cut and add ellipsis
+ const OUString& rFullText = maFields[ nFieldIndex ].maFieldName;
+ OUString aClippedText = rFullText;
+ long nLabelWidth = rDev.GetTextWidth( rFullText );
+ if( (maFields[ nFieldIndex ].mbClipped = nLabelWidth + 6 > maFieldSize.Width()) == true )
{
- // added to avoid warnings
+ sal_Int32 nMinLen = 0;
+ sal_Int32 nMaxLen = rFullText.getLength();
+ bool bFits = false;
+ do
+ {
+ sal_Int32 nCurrLen = (nMinLen + nMaxLen) / 2;
+ aClippedText = rFullText.copy( 0, nCurrLen ) + OUString( RTL_CONSTASCII_USTRINGPARAM( "..." ) );
+ nLabelWidth = rDev.GetTextWidth( aClippedText );
+ bFits = nLabelWidth + 6 <= maFieldSize.Width();
+ (bFits ? nMinLen : nMaxLen) = nCurrLen;
+ }
+ while( !bFits || (nMinLen + 1 < nMaxLen) );
}
+
+ // draw the button text
+ Point aLabelOffset( (maFieldSize.Width() - nLabelWidth) / 2, ::std::max< long >( (maFieldSize.Height() - rDev.GetTextHeight()) / 2, 3 ) );
+ rDev.SetTextColor( GetSettings().GetStyleSettings().GetButtonTextColor() );
+ rDev.DrawText( aFieldPos + aLabelOffset, aClippedText );
}
- return sDescription;
}
-::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScDPFieldWindow::CreateAccessible()
+void ScPivotFieldWindow::DrawInsertionCursor( OutputDevice& rDev )
{
- pAccessible =
- new ScAccessibleDataPilotControl(GetAccessibleParentWindow()->GetAccessible(), this);
+ if( (mnInsCursorIndex <= maFields.size()) && (mnFirstVisIndex <= mnInsCursorIndex) && (mnInsCursorIndex <= mnFirstVisIndex + mnPageSize) &&
+ (!mbIsTrackingSource || (mnInsCursorIndex < mnSelectIndex) || (mnInsCursorIndex > mnSelectIndex + 1)) )
+ {
+ Color aTextColor = GetSettings().GetStyleSettings().GetButtonTextColor();
+ rDev.SetLineColor( aTextColor );
+ rDev.SetFillColor( aTextColor );
- com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xReturn = pAccessible;
+ bool bVerticalCursor = mnColCount > 1;
+ long nCursorLength = bVerticalCursor ? maFieldSize.Height() : maFieldSize.Width();
- pAccessible->Init();
- xAccessible = xReturn;
+ bool bEndOfLastField = mnInsCursorIndex == mnFirstVisIndex + mnPageSize;
+ Point aMainLinePos = GetFieldPosition( bEndOfLastField ? (mnInsCursorIndex - 1) : mnInsCursorIndex );
+ if( bEndOfLastField )
+ (bVerticalCursor ? aMainLinePos.X() : aMainLinePos.Y()) += ((bVerticalCursor ? maFieldSize.Width() : maFieldSize.Height()) - CURSOR_WIDTH);
+ else if( (bVerticalCursor ? aMainLinePos.X() : aMainLinePos.Y()) > 0 )
+ (bVerticalCursor ? aMainLinePos.X() : aMainLinePos.Y()) -= ((CURSOR_WIDTH + 1) / 2);
+ Size aMainLineSize( bVerticalCursor ? CURSOR_WIDTH : nCursorLength, bVerticalCursor ? nCursorLength : CURSOR_WIDTH );
+ rDev.DrawRect( Rectangle( aMainLinePos, aMainLineSize ) );
- return xReturn;
+ Point aSubLinePos = aMainLinePos;
+ (bVerticalCursor ? aSubLinePos.X() : aSubLinePos.Y()) -= CURSOR_WIDTH;
+ Size aSubLineSize( bVerticalCursor ? (3 * CURSOR_WIDTH) : CURSOR_WIDTH, bVerticalCursor ? CURSOR_WIDTH : (3 * CURSOR_WIDTH) );
+ rDev.DrawRect( Rectangle( aSubLinePos, aSubLineSize ) );
+
+ (bVerticalCursor ? aSubLinePos.Y() : aSubLinePos.X()) += (nCursorLength - CURSOR_WIDTH);
+ rDev.DrawRect( Rectangle( aSubLinePos, aSubLineSize ) );
+ }
}
-//===================================================================
+::rtl::Reference< ScAccessibleDataPilotControl > ScPivotFieldWindow::GetAccessibleControl()
+{
+ ::rtl::Reference< ScAccessibleDataPilotControl > xAccImpl;
+ if( mpAccessible )
+ {
+ // try to resolve the weak reference mxAccessible
+ uno::Reference< accessibility::XAccessible > xAcc = mxAccessible;
+ if( xAcc.is() )
+ xAccImpl.set( mpAccessible ); // the rtl reference keeps the object alive
+ else
+ mpAccessible = 0; // object is dead, forget the pointer
+ }
+ return xAccImpl;
+ }
+
+// handlers -------------------------------------------------------------------
+
+IMPL_LINK( ScPivotFieldWindow, ScrollHdl, ScrollBar*, pScrollBar )
+{
+ // scrollbar may return negative values, if it is too small
+ long nThumbPos = pScrollBar->GetThumbPos();
+ if( nThumbPos >= 0 )
+ {
+ size_t nNewFirstVisIndex = static_cast< size_t >( nThumbPos * mnLineSize );
+ // keep the selection index on same relative position inside row/column
+ size_t nSelectLineOffset = mnSelectIndex % mnLineSize;
+ size_t nNewSelectIndex = mnSelectIndex;
+ if( nNewSelectIndex < nNewFirstVisIndex )
+ nNewSelectIndex = nNewFirstVisIndex + nSelectLineOffset;
+ else if( nNewSelectIndex >= nNewFirstVisIndex + mnPageSize )
+ nNewSelectIndex = nNewFirstVisIndex + mnPageSize - mnLineSize + nSelectLineOffset;
+ nNewSelectIndex = ::std::min( nNewSelectIndex, maFields.size() - 1 );
+ SetSelectionUnchecked( nNewSelectIndex, nNewFirstVisIndex );
+ }
+ GrabFocus();
+ return 0;
+}
+// ============================================================================
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
index 5b2b7b47fdd2..8e2bbc7458c3 100644
--- a/sc/source/ui/dbgui/filtdlg.cxx
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -132,6 +132,65 @@ ScFilterDlg::ScFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
pTimer = new Timer;
pTimer->SetTimeout( 50 ); // 50ms warten
pTimer->SetTimeoutHdl( LINK( this, ScFilterDlg, TimeOutHdl ) );
+
+ String sAccName (ScResId(RID_FILTER_OPERATOR));
+ String sIndexName(sAccName);
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
+ aLbConnect1.SetAccessibleName(sIndexName);
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
+ aLbConnect2.SetAccessibleName(sIndexName);
+
+ sAccName = String(ScResId(RID_FILTER_FIELDNAME));
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
+ aLbField1.SetAccessibleName(sIndexName);
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
+ aLbField2.SetAccessibleName(sIndexName);
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
+ aLbField3.SetAccessibleName(sIndexName);
+
+
+ sAccName = String(ScResId(RID_FILTER_CONDITION));
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
+ aLbCond1.SetAccessibleName(sIndexName);
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
+ aLbCond2.SetAccessibleName(sIndexName);
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
+ aLbCond3.SetAccessibleName(sIndexName);
+
+ sAccName = String(ScResId(RID_FILTER_VALUE));
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
+ aEdVal1.SetAccessibleName(sIndexName);
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
+ aEdVal2.SetAccessibleName(sIndexName);
+ sIndexName = sAccName;
+ sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
+ aEdVal3.SetAccessibleName(sIndexName);
+
+ aLbCopyArea.SetAccessibleName(ScResId(STR_COPY_AREA_TO));
+ aEdCopyArea.SetAccessibleName(ScResId(STR_COPY_AREA_TO));
+ aLbCopyArea.SetAccessibleRelationLabeledBy(&aBtnCopyResult);
+ aEdCopyArea.SetAccessibleRelationLabeledBy(&aBtnCopyResult);
+
+ aLbConnect1.SetAccessibleRelationLabeledBy(&aFtConnect);
+ aLbConnect2.SetAccessibleRelationLabeledBy(&aFtConnect);
+ aLbField1.SetAccessibleRelationLabeledBy(&aFtField);
+ aLbField2.SetAccessibleRelationLabeledBy(&aFtField);
+ aLbField3.SetAccessibleRelationLabeledBy(&aFtField);
+ aLbCond1.SetAccessibleRelationLabeledBy(&aFtCond);
+ aLbCond2.SetAccessibleRelationLabeledBy(&aFtCond);
+ aLbCond3.SetAccessibleRelationLabeledBy(&aFtCond);
+ aEdVal1.SetAccessibleRelationLabeledBy(&aFtVal);
+ aEdVal2.SetAccessibleRelationLabeledBy(&aFtVal);
+ aEdVal3.SetAccessibleRelationLabeledBy(&aFtVal);
}
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
index 64456ef2cf2d..b21afc999b28 100644
--- a/sc/source/ui/dbgui/imoptdlg.cxx
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
@@ -44,10 +44,20 @@ static const sal_Char pStrFix[] = "FIX";
ScImportOptions::ScImportOptions( const String& rStr )
{
+ // Use the same string format as ScAsciiOptions,
+ // because the import options string is passed here when a CSV file is loaded and saved again.
+ // The old format is still supported because it might be used in macros.
+
bFixedWidth = sal_False;
nFieldSepCode = 0;
- if ( rStr.GetTokenCount(',') >= 3 )
+ nTextSepCode = 0;
+ eCharSet = RTL_TEXTENCODING_DONTKNOW;
+ bSaveAsShown = sal_True; // "true" if not in string (after CSV import)
+ bQuoteAllText = sal_False;
+ xub_StrLen nTokenCount = rStr.GetTokenCount(',');
+ if ( nTokenCount >= 3 )
{
+ // first 3 tokens: common
String aToken( rStr.GetToken( 0, ',' ) );
if( aToken.EqualsIgnoreCaseAscii( pStrFix ) )
bFixedWidth = sal_True;
@@ -56,7 +66,21 @@ ScImportOptions::ScImportOptions( const String& rStr )
nTextSepCode = (sal_Unicode) rStr.GetToken(1,',').ToInt32();
aStrFont = rStr.GetToken(2,',');
eCharSet = ScGlobal::GetCharsetValue(aStrFont);
- bSaveAsShown = (rStr.GetToken( 3, ',' ).ToInt32() ? sal_True : sal_False);
+
+ if ( nTokenCount == 4 )
+ {
+ // compatibility with old options string: "Save as shown" as 4th token, numeric
+ bSaveAsShown = (rStr.GetToken( 3, ',' ).ToInt32() ? sal_True : sal_False);
+ bQuoteAllText = sal_True; // use old default then
+ }
+ else
+ {
+ // look at the same positions as in ScAsciiOptions
+ if ( nTokenCount >= 7 )
+ bQuoteAllText = rStr.GetToken(6, ',').EqualsAscii("true");
+ if ( nTokenCount >= 9 )
+ bSaveAsShown = rStr.GetToken(8, ',').EqualsAscii("true");
+ }
}
}
@@ -74,8 +98,11 @@ String ScImportOptions::BuildString() const
aResult += String::CreateFromInt32(nTextSepCode);
aResult += ',';
aResult += aStrFont;
- aResult += ',';
- aResult += String::CreateFromInt32( bSaveAsShown ? 1 : 0 );
+ // use the same string format as ScAsciiOptions:
+ aResult.AppendAscii( ",1,,0," ); // first row, no column info, default language
+ aResult.AppendAscii(bQuoteAllText ? "true" : "false"); // same as "quoted field as text" in ScAsciiOptions
+ aResult.AppendAscii( ",true," ); // "detect special numbers"
+ aResult.AppendAscii(bSaveAsShown ? "true" : "false"); // "save as shown": not in ScAsciiOptions
return aResult;
}
diff --git a/sc/source/ui/dbgui/imoptdlg.hrc b/sc/source/ui/dbgui/imoptdlg.hrc
index 5fd9256e8009..22136706de9d 100644
--- a/sc/source/ui/dbgui/imoptdlg.hrc
+++ b/sc/source/ui/dbgui/imoptdlg.hrc
@@ -41,4 +41,5 @@
#define FL_FIELDOPT 11
#define CB_FIXEDWIDTH 12
#define CB_SAVESHOWN 13
+#define CB_QUOTEALL 14
diff --git a/sc/source/ui/dbgui/imoptdlg.src b/sc/source/ui/dbgui/imoptdlg.src
index e83f3a9c9dac..905308e9fecb 100644
--- a/sc/source/ui/dbgui/imoptdlg.src
+++ b/sc/source/ui/dbgui/imoptdlg.src
@@ -96,7 +96,7 @@ ModalDialog RID_SCDLG_IMPORTOPT
CheckBox CB_FIXEDWIDTH
{
HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_FIXEDWIDTH";
- Pos = MAP_APPFONT( 12, 80 );
+ Pos = MAP_APPFONT( 12, 92 );
Size = MAP_APPFONT( 172, 10 );
Hide = TRUE;
Text [ en-US ] = "Fixed column ~width";
@@ -104,12 +104,20 @@ ModalDialog RID_SCDLG_IMPORTOPT
CheckBox CB_SAVESHOWN
{
HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_SAVESHOWN";
- Pos = MAP_APPFONT( 12, 66 );
+ Pos = MAP_APPFONT( 12, 78 );
Size = MAP_APPFONT( 172, 10 );
TabStop = TRUE;
Hide = TRUE;
Text [ en-US ] = "Save cell content as ~shown";
};
+ CheckBox CB_QUOTEALL
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_QUOTEALL";
+ Pos = MAP_APPFONT( 20, 64 );
+ Size = MAP_APPFONT( 164, 10 );
+ Hide = TRUE;
+ Text [ en-US ] = "~Quote all text cells";
+ };
OKButton BTN_OK
{
Pos = MAP_APPFONT ( 202 , 6 ) ;
diff --git a/sc/source/ui/dbgui/pivot.hrc b/sc/source/ui/dbgui/pivot.hrc
index 1a97d4c75b52..fd14c0f98a6b 100644
--- a/sc/source/ui/dbgui/pivot.hrc
+++ b/sc/source/ui/dbgui/pivot.hrc
@@ -34,13 +34,16 @@
#define BTN_OPTIONS 6
#define FL_LAYOUT 10
+#define FL_SELECT 90
+#define SCROLL_COL 91
#define WND_COL 11
+#define SCROLL_ROW 92
#define WND_ROW 12
+#define SCROLL_DATA 93
#define WND_DATA 13
#define WND_SELECT 14
-#define WND_FIELD 15
-#define WND_FIELD_SPACE 16
#define WND_HSCROLL 17
+#define SCROLL_PAGE 98
#define WND_PAGE 18
#define FT_COL 31
#define FT_ROW 32
diff --git a/sc/source/ui/dbgui/pivot.src b/sc/source/ui/dbgui/pivot.src
index 763f03fe82bf..52b1a9d584cd 100644
--- a/sc/source/ui/dbgui/pivot.src
+++ b/sc/source/ui/dbgui/pivot.src
@@ -31,12 +31,12 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
{
OutputSize = TRUE ;
HelpId = CMD_SID_OPENDLG_PIVOTTABLE ;
- Size = MAP_APPFONT ( 336 , 190 ) ;
+ Size = MAP_APPFONT ( 348 , 186 ) ;
Hide = TRUE ;
SVLook = TRUE ;
Moveable = TRUE ;
Closeable = FALSE ;
- Text [ en-US ] = "DataPilot" ;
+ Text [ en-US ] = "Pivot Table" ;
FixedText FT_PAGE
{
@@ -44,10 +44,17 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
Size = MAP_APPFONT ( 37 , 8 ) ;
Text[ en-US ] = "Page Fields" ;
};
+ ScrollBar SCROLL_PAGE
+ {
+ Pos = MAP_APPFONT ( 198 , 14 ) ;
+ Size = MAP_APPFONT ( 8 , 24 ) ;
+ HScroll = FALSE ;
+ TabStop = FALSE ;
+ };
Control WND_PAGE
{
- Pos = MAP_APPFONT ( 6 , 14 ) ;
- Size = MAP_APPFONT ( 182 , 24 ) ;
+ Pos = MAP_APPFONT ( 18 , 14 ) ;
+ Size = MAP_APPFONT ( 180 , 24 ) ;
TabStop = TRUE ;
};
FixedText FT_COL
@@ -56,9 +63,16 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
Size = MAP_APPFONT ( 37 , 8 ) ;
Text [ en-US ] = "Column Fields" ;
};
+ ScrollBar SCROLL_COL
+ {
+ Pos = MAP_APPFONT ( 198 , 42 ) ;
+ Size = MAP_APPFONT ( 8 , 24 ) ;
+ HScroll = FALSE ;
+ TabStop = FALSE ;
+ };
Control WND_COL
{
- Pos = MAP_APPFONT ( 44 , 40 ) ;
+ Pos = MAP_APPFONT ( 54 , 42 ) ;
Size = MAP_APPFONT ( 144 , 24 ) ;
TabStop = TRUE ;
};
@@ -68,9 +82,16 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
Size = MAP_APPFONT ( 37 , 8 ) ;
Text [ en-US ] = "Row\nFields" ;
};
+ ScrollBar SCROLL_ROW
+ {
+ Pos = MAP_APPFONT ( 42 , 70 ) ;
+ Size = MAP_APPFONT ( 8 , 96 ) ;
+ HScroll = FALSE ;
+ TabStop = FALSE ;
+ };
Control WND_ROW
{
- Pos = MAP_APPFONT ( 6 , 66 ) ;
+ Pos = MAP_APPFONT ( 6 , 70 ) ;
Size = MAP_APPFONT ( 36 , 96 ) ;
TabStop = TRUE ;
};
@@ -80,16 +101,23 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
Size = MAP_APPFONT ( 37 , 8 ) ;
Text [ en-US ] = "Data Fields" ;
};
+ ScrollBar SCROLL_DATA
+ {
+ Pos = MAP_APPFONT ( 198 , 70 ) ;
+ Size = MAP_APPFONT ( 8 , 96 ) ;
+ HScroll = FALSE ;
+ TabStop = FALSE ;
+ };
Control WND_DATA
{
- Pos = MAP_APPFONT ( 44 , 66 ) ;
+ Pos = MAP_APPFONT ( 54 , 70 ) ;
Size = MAP_APPFONT ( 144 , 96 ) ;
TabStop = TRUE ;
};
Control WND_SELECT
{
- Pos = MAP_APPFONT ( 194 , 14 ) ;
- Size = MAP_APPFONT ( 70 , 126 ) ;
+ Pos = MAP_APPFONT ( 212 , 14 ) ;
+ Size = MAP_APPFONT ( 74 , 138 ) ;
TabStop = TRUE ;
};
String STR_SELECT
@@ -98,47 +126,53 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
};
ScrollBar WND_HSCROLL
{
- Pos = MAP_APPFONT ( 194 , 144 ) ;
- Size = MAP_APPFONT ( 70 , 8 ) ;
+ Pos = MAP_APPFONT ( 212 , 154 ) ;
+ Size = MAP_APPFONT ( 74 , 8 ) ;
HScroll = TRUE ;
TabStop = FALSE ;
};
FixedText FT_INFO
{
- Pos = MAP_APPFONT ( 6 , 168 ) ;
- Size = MAP_APPFONT ( 182 , 16 ) ;
+ Pos = MAP_APPFONT ( 6 , 172 ) ;
+ Size = MAP_APPFONT ( 280 , 8 ) ;
WordBreak = TRUE ;
Text [ en-US ] = "Drag the fields from the right into the desired position." ;
};
FixedLine FL_LAYOUT
{
Pos = MAP_APPFONT ( 6 , 3 ) ;
- Size = MAP_APPFONT ( 268 , 8 ) ;
+ Size = MAP_APPFONT ( 200 , 8 ) ;
Text [ en-US ] = "Layout";
};
+ FixedLine FL_SELECT
+ {
+ Pos = MAP_APPFONT ( 212 , 3 ) ;
+ Size = MAP_APPFONT ( 74 , 8 ) ;
+ Text [ en-US ] = "Fields";
+ };
OKButton BTN_OK
{
- Pos = MAP_APPFONT ( 280 , 6 ) ;
+ Pos = MAP_APPFONT ( 292 , 6 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
TabStop = TRUE ;
DefButton = TRUE ;
};
CancelButton BTN_CANCEL
{
- Pos = MAP_APPFONT ( 280 , 23 ) ;
+ Pos = MAP_APPFONT ( 292 , 23 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
TabStop = TRUE ;
};
HelpButton BTN_HELP
{
- Pos = MAP_APPFONT ( 280 , 43 ) ;
+ Pos = MAP_APPFONT ( 292 , 43 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
TabStop = TRUE ;
};
PushButton BTN_REMOVE
{
HelpID = "sc:PushButton:RID_SCDLG_PIVOT_LAYOUT:BTN_REMOVE";
- Pos = MAP_APPFONT ( 280 , 63 ) ;
+ Pos = MAP_APPFONT ( 292 , 63 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
TabStop = TRUE ;
Text [ en-US ] = "Remove";
@@ -146,7 +180,7 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
PushButton BTN_OPTIONS
{
HelpID = "sc:PushButton:RID_SCDLG_PIVOT_LAYOUT:BTN_OPTIONS";
- Pos = MAP_APPFONT ( 280 , 80 ) ;
+ Pos = MAP_APPFONT ( 292 , 80 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
TabStop = TRUE ;
Text [ en-US ] = "Options...";
@@ -154,34 +188,23 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
MoreButton BTN_MORE
{
HelpID = "sc:MoreButton:RID_SCDLG_PIVOT_LAYOUT:BTN_MORE";
- Pos = MAP_APPFONT ( 280 , 170 ) ;
+ Pos = MAP_APPFONT ( 292 , 166 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
TabStop = TRUE ;
MapUnit = MAP_APPFONT ;
Delta = 90 ;
};
- Window WND_FIELD
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( 0 , 0 ) ;
- Size = MAP_APPFONT ( 36 , 12 ) ;
- };
- Window WND_FIELD_SPACE
- {
- Pos = MAP_APPFONT ( 0 , 0 ) ;
- Size = MAP_APPFONT ( 2 , 2 ) ;
- };
FixedLine FL_OUTPUT
{
- Pos = MAP_APPFONT ( 6 , 190 ) ;
- Size = MAP_APPFONT ( 268 , 8 ) ;
+ Pos = MAP_APPFONT ( 6 , 186 ) ;
+ Size = MAP_APPFONT ( 280 , 8 ) ;
Text [ en-US ] = "Result" ;
Hide = TRUE ;
};
FixedText FT_INAREA
{
- Pos = MAP_APPFONT ( 12 , 203 ) ;
+ Pos = MAP_APPFONT ( 12 , 199 ) ;
Size = MAP_APPFONT ( 59 , 8 ) ;
Hide = TRUE ;
Text [ en-US ] = "Selection from" ;
@@ -190,15 +213,15 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
{
HelpID = "sc:Edit:RID_SCDLG_PIVOT_LAYOUT:ED_INAREA";
Border = TRUE ;
- Pos = MAP_APPFONT ( 73 , 201 ) ;
- Size = MAP_APPFONT ( 100 , 12 ) ;
+ Pos = MAP_APPFONT ( 73 , 197 ) ;
+ Size = MAP_APPFONT ( 109 , 12 ) ;
TabStop = TRUE ;
Hide = TRUE ;
};
ImageButton RB_INAREA
{
HelpID = "sc:ImageButton:RID_SCDLG_PIVOT_LAYOUT:RB_INAREA";
- Pos = MAP_APPFONT ( 177 , 200 ) ;
+ Pos = MAP_APPFONT ( 186 , 196 ) ;
Size = MAP_APPFONT ( 13 , 15 ) ;
TabStop = TRUE ;
Hide = TRUE ;
@@ -207,7 +230,7 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
FixedText FT_OUTAREA
{
- Pos = MAP_APPFONT ( 12 , 221 ) ;
+ Pos = MAP_APPFONT ( 12 , 217 ) ;
Size = MAP_APPFONT ( 59 , 8 ) ;
Hide = TRUE ;
Text [ en-US ] = "Results to" ;
@@ -216,7 +239,7 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
{
HelpID = "sc:ListBox:RID_SCDLG_PIVOT_LAYOUT:LB_OUTAREA";
Border = TRUE ;
- Pos = MAP_APPFONT ( 73 , 219 ) ;
+ Pos = MAP_APPFONT ( 73 , 215 ) ;
Size = MAP_APPFONT ( 75 , 90 ) ;
TabStop = TRUE ;
DropDown = TRUE ;
@@ -226,15 +249,15 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
{
HelpID = "sc:Edit:RID_SCDLG_PIVOT_LAYOUT:ED_OUTAREA";
Border = TRUE ;
- Pos = MAP_APPFONT ( 152 , 219 ) ;
- Size = MAP_APPFONT ( 100 , 12 ) ;
+ Pos = MAP_APPFONT ( 152 , 215 ) ;
+ Size = MAP_APPFONT ( 109 , 12 ) ;
TabStop = TRUE ;
Hide = TRUE ;
};
ImageButton RB_OUTAREA
{
HelpID = "sc:ImageButton:RID_SCDLG_PIVOT_LAYOUT:RB_OUTAREA";
- Pos = MAP_APPFONT ( 256 , 218 ) ;
+ Pos = MAP_APPFONT ( 265 , 214 ) ;
Size = MAP_APPFONT ( 13 , 15 ) ;
TabStop = TRUE ;
Hide = TRUE ;
@@ -243,8 +266,8 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
CheckBox BTN_IGNEMPTYROWS
{
HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_IGNEMPTYROWS";
- Pos = MAP_APPFONT ( 12 , 237 ) ;
- Size = MAP_APPFONT ( 124 , 10 ) ;
+ Pos = MAP_APPFONT ( 12 , 233 ) ;
+ Size = MAP_APPFONT ( 136 , 10 ) ;
TabStop = TRUE ;
Hide = TRUE ;
Text [ en-US ] = "Ignore ~empty rows" ;
@@ -252,8 +275,8 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
CheckBox BTN_DETECTCAT
{
HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_DETECTCAT";
- Pos = MAP_APPFONT ( 142 , 237 ) ;
- Size = MAP_APPFONT ( 124 , 10 ) ;
+ Pos = MAP_APPFONT ( 152 , 233 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
TabStop = TRUE ;
Hide = TRUE ;
Text [ en-US ] = "~Identify categories" ;
@@ -261,8 +284,8 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
CheckBox BTN_TOTALCOL
{
HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_TOTALCOL";
- Pos = MAP_APPFONT ( 12 , 251 ) ;
- Size = MAP_APPFONT ( 124 , 10 ) ;
+ Pos = MAP_APPFONT ( 12 , 247 ) ;
+ Size = MAP_APPFONT ( 136 , 10 ) ;
TabStop = TRUE ;
Hide = TRUE ;
Text [ en-US ] = "Total columns" ;
@@ -270,8 +293,8 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
CheckBox BTN_TOTALROW
{
HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_TOTALROW";
- Pos = MAP_APPFONT ( 142 , 251 ) ;
- Size = MAP_APPFONT ( 124 , 10 ) ;
+ Pos = MAP_APPFONT ( 152 , 247 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
TabStop = TRUE ;
Hide = TRUE ;
Text [ en-US ] = "~Total rows" ;
@@ -279,8 +302,8 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
CheckBox BTN_FILTER
{
HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_FILTER";
- Pos = MAP_APPFONT ( 12 , 265 ) ;
- Size = MAP_APPFONT ( 124 , 10 ) ;
+ Pos = MAP_APPFONT ( 12 , 261 ) ;
+ Size = MAP_APPFONT ( 136 , 10 ) ;
TabStop = TRUE ;
Hide = TRUE ;
Text [ en-US ] = "~Add filter" ;
@@ -288,8 +311,8 @@ ModelessDialog RID_SCDLG_PIVOT_LAYOUT
CheckBox BTN_DRILLDOWN
{
HelpID = "sc:CheckBox:RID_SCDLG_PIVOT_LAYOUT:BTN_DRILLDOWN";
- Pos = MAP_APPFONT ( 142 , 265 ) ;
- Size = MAP_APPFONT ( 124 , 10 ) ;
+ Pos = MAP_APPFONT ( 152 , 261 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
TabStop = TRUE ;
Hide = TRUE ;
Text [ en-US ] = "Ena~ble drill to details" ;
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index 794e7361338e..5ee9b320a04e 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -209,8 +209,8 @@ void ScDPFunctionListBox::FillFunctionNames()
// ============================================================================
ScDPFunctionDlg::ScDPFunctionDlg(
- Window* pParent, const ScDPLabelDataVec& rLabelVec,
- const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData ) :
+ Window* pParent, const ScDPLabelDataVector& rLabelVec,
+ const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData ) :
ModalDialog ( pParent, ScResId( RID_SCDLG_DPDATAFIELD ) ),
maFlFunc ( this, ScResId( FL_FUNC ) ),
maLbFunc ( this, ScResId( LB_FUNC ) ),
@@ -267,7 +267,7 @@ DataPilotFieldReference ScDPFunctionDlg::GetFieldRef() const
return aRef;
}
-void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
+void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData )
{
// list box
sal_uInt16 nFuncMask = (rFuncData.mnFuncMask == PIVOT_FUNC_NONE) ? PIVOT_FUNC_SUM : rFuncData.mnFuncMask;
@@ -291,7 +291,7 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData&
maLbBaseField.SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
// base field list box
- for( ScDPLabelDataVec::const_iterator aIt = mrLabelVec.begin(), aEnd = mrLabelVec.end(); aIt != aEnd; ++aIt )
+ for( ScDPLabelDataVector::const_iterator aIt = mrLabelVec.begin(), aEnd = mrLabelVec.end(); aIt != aEnd; ++aIt )
maLbBaseField.InsertEntry(aIt->getDisplayName());
// base item list box
@@ -393,7 +393,7 @@ IMPL_LINK( ScDPFunctionDlg, DblClickHdl, MultiListBox*, EMPTYARG )
// ============================================================================
ScDPSubtotalDlg::ScDPSubtotalDlg( Window* pParent, ScDPObject& rDPObj,
- const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData,
+ const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData,
const ScDPNameVec& rDataFields, bool bEnableLayout ) :
ModalDialog ( pParent, ScResId( RID_SCDLG_PIVOTSUBT ) ),
maFlSubt ( this, ScResId( FL_FUNC ) ),
@@ -440,7 +440,7 @@ void ScDPSubtotalDlg::FillLabelData( ScDPLabelData& rLabelData ) const
rLabelData.maShowInfo = maLabelData.maShowInfo;
}
-void ScDPSubtotalDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
+void ScDPSubtotalDlg::Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData )
{
// field name
maFtName.SetText(rLabelData.getDisplayName());
diff --git a/sc/source/ui/dbgui/pvglob.hxx b/sc/source/ui/dbgui/pvglob.hxx
deleted file mode 100644
index 6b6526266035..000000000000
--- a/sc/source/ui/dbgui/pvglob.hxx
+++ /dev/null
@@ -1,42 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef SC_PVGLOB_HXX
-#define SC_PVGLOB_HXX
-
-//-------------------------------------------------------------------
-
-class PivotGlobal
-{
-public:
- static long nObjHeight;
- static long nObjWidth;
- static long nSelSpace;
-};
-
-
-#endif // SC_PVGLOB_HXX
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 10134e696571..b43779ffa62b 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -28,19 +28,16 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
-
-
-//----------------------------------------------------------------------------
-
#include "pvlaydlg.hxx"
-#include "dbdocfun.hxx"
-
-#include <sfx2/dispatch.hxx>
-#include <vcl/msgbox.hxx>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+#include <sfx2/dispatch.hxx>
+#include <vcl/mnemonic.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "dbdocfun.hxx"
#include "uiitems.hxx"
#include "rangeutl.hxx"
#include "document.hxx"
@@ -48,8 +45,6 @@
#include "tabvwsh.hxx"
#include "reffact.hxx"
#include "scresid.hxx"
-#include "pvglob.hxx"
-//CHINA001 #include "pvfundlg.hxx"
#include "globstr.hrc"
#include "pivot.hrc"
#include "dpobject.hxx"
@@ -59,221 +54,140 @@
#include "sc.hrc" //CHINA001
#include "scabstdlg.hxx" //CHINA001
-using namespace com::sun::star;
-using ::rtl::OUString;
-using ::std::vector;
-
-//----------------------------------------------------------------------------
-
-#define FSTR(index) aFuncNameArr[index-1]
-#define STD_FORMAT SCA_VALID | SCA_TAB_3D \
- | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
-long PivotGlobal::nObjHeight = 0; // initialized with resource data
-long PivotGlobal::nObjWidth = 0;
-long PivotGlobal::nSelSpace = 0;
+// ============================================================================
+using namespace ::com::sun::star;
+using ::rtl::OUString;
-//============================================================================
+// ============================================================================
namespace {
-void lcl_FillToPivotField( PivotField& rPivotField, const ScDPFuncData& rFuncData )
-{
- rPivotField.nCol = rFuncData.mnCol;
- rPivotField.nFuncMask = rFuncData.mnFuncMask;
- rPivotField.maFieldRef = rFuncData.maFieldRef;
-}
+const sal_uInt16 STD_FORMAT = sal_uInt16( SCA_VALID | SCA_TAB_3D | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE );
-PointerStyle lclGetPointerForField( ScDPFieldType eType )
+OUString lclGetNameWithoutMnemonic( const FixedText& rFixedText )
{
- switch( eType )
- {
- case TYPE_PAGE: return POINTER_PIVOT_FIELD;
- case TYPE_COL: return POINTER_PIVOT_COL;
- case TYPE_ROW: return POINTER_PIVOT_ROW;
- case TYPE_DATA: return POINTER_PIVOT_FIELD;
- case TYPE_SELECT: return POINTER_PIVOT_FIELD;
- }
- return POINTER_ARROW;
+ return MnemonicGenerator::EraseAllMnemonicChars( rFixedText.GetText() );
}
} // namespace
-//============================================================================
-
-//----------------------------------------------------------------------------
-
-ScDPLayoutDlg::ScDPLayoutDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
- const ScDPObject& rDPObject )
- : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_PIVOT_LAYOUT ),
- aFlLayout ( this, ScResId( FL_LAYOUT ) ),
- aFtPage ( this, ScResId( FT_PAGE ) ),
- aWndPage ( this, ScResId( WND_PAGE ), TYPE_PAGE, &aFtPage ),
- aFtCol ( this, ScResId( FT_COL ) ),
- aWndCol ( this, ScResId( WND_COL ), TYPE_COL, &aFtCol ),
- aFtRow ( this, ScResId( FT_ROW ) ),
- aWndRow ( this, ScResId( WND_ROW ), TYPE_ROW, &aFtRow ),
- aFtData ( this, ScResId( FT_DATA ) ),
- aWndData ( this, ScResId( WND_DATA ), TYPE_DATA, &aFtData ),
- aWndSelect ( this, ScResId( WND_SELECT ), TYPE_SELECT, String(ScResId(STR_SELECT)) ),
- aSlider ( this, ScResId( WND_HSCROLL ) ),
- aFtInfo ( this, ScResId( FT_INFO ) ),
-
- aFlAreas ( this, ScResId( FL_OUTPUT ) ),
-
- aFtInArea ( this, ScResId( FT_INAREA) ),
- aEdInPos ( this, ScResId( ED_INAREA) ),
- aRbInPos ( this, ScResId( RB_INAREA ), &aEdInPos, this ),
-
- aLbOutPos ( this, ScResId( LB_OUTAREA ) ),
- aFtOutArea ( this, ScResId( FT_OUTAREA ) ),
- aEdOutPos ( this, this, ScResId( ED_OUTAREA ) ),
- aRbOutPos ( this, ScResId( RB_OUTAREA ), &aEdOutPos, this ),
- aBtnIgnEmptyRows( this, ScResId( BTN_IGNEMPTYROWS ) ),
- aBtnDetectCat ( this, ScResId( BTN_DETECTCAT ) ),
- aBtnTotalCol ( this, ScResId( BTN_TOTALCOL ) ),
- aBtnTotalRow ( this, ScResId( BTN_TOTALROW ) ),
- aBtnFilter ( this, ScResId( BTN_FILTER ) ),
- aBtnDrillDown ( this, ScResId( BTN_DRILLDOWN ) ),
-
- aBtnOk ( this, ScResId( BTN_OK ) ),
- aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- aBtnHelp ( this, ScResId( BTN_HELP ) ),
- aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
- aBtnOptions ( this, ScResId( BTN_OPTIONS ) ),
- aBtnMore ( this, ScResId( BTN_MORE ) ),
-
- aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
- aStrNewTable ( ScResId( SCSTR_NEWTABLE ) ),
-
- bIsDrag ( sal_False ),
-
- pEditActive ( NULL ),
-
- eLastActiveType ( TYPE_SELECT ),
- nOffset ( 0 ),
- //
- xDlgDPObject ( new ScDPObject( rDPObject ) ),
- pViewData ( ((ScTabViewShell*)SfxViewShell::Current())->
- GetViewData() ),
- pDoc ( ((ScTabViewShell*)SfxViewShell::Current())->
- GetViewData()->GetDocument() ),
- bRefInputMode ( sal_False )
-{
- xDlgDPObject->SetAlive( sal_True ); // needed to get structure information
- xDlgDPObject->FillOldParam( thePivotData, sal_False );
- xDlgDPObject->FillLabelData( thePivotData );
-
- Init();
- FreeResource();
-}
-
-
-//----------------------------------------------------------------------------
-
-ScDPLayoutDlg::~ScDPLayoutDlg()
-{
- sal_uInt16 nEntries = aLbOutPos.GetEntryCount();
- sal_uInt16 i;
-
- for ( i=2; i<nEntries; i++ )
- delete (String*)aLbOutPos.GetEntryData( i );
-}
-
-
-//----------------------------------------------------------------------------
-
-ScDPFieldWindow& ScDPLayoutDlg::GetFieldWindow( ScDPFieldType eType )
-{
- switch( eType )
- {
- case TYPE_PAGE: return aWndPage;
- case TYPE_ROW: return aWndRow;
- case TYPE_COL: return aWndCol;
- case TYPE_DATA: return aWndData;
- default:
- {
- // added to avoid warnings
- }
- }
- return aWndSelect;
-}
-
-void __EXPORT ScDPLayoutDlg::Init()
-{
- DBG_ASSERT( pViewData && pDoc,
- "Ctor-Initialisierung fehlgeschlagen!" );
-
- aBtnRemove.SetClickHdl( LINK( this, ScDPLayoutDlg, ClickHdl ) );
- aBtnOptions.SetClickHdl( LINK( this, ScDPLayoutDlg, ClickHdl ) );
-
- aFuncNameArr.reserve( FUNC_COUNT );
- for ( sal_uInt16 i = 0; i < FUNC_COUNT; ++i )
- aFuncNameArr.push_back( String( ScResId( i + 1 ) ) );
-
- aBtnMore.AddWindow( &aFlAreas );
- aBtnMore.AddWindow( &aFtInArea );
- aBtnMore.AddWindow( &aEdInPos );
- aBtnMore.AddWindow( &aRbInPos );
- aBtnMore.AddWindow( &aFtOutArea );
- aBtnMore.AddWindow( &aLbOutPos );
- aBtnMore.AddWindow( &aEdOutPos );
- aBtnMore.AddWindow( &aRbOutPos );
- aBtnMore.AddWindow( &aBtnIgnEmptyRows );
- aBtnMore.AddWindow( &aBtnDetectCat );
- aBtnMore.AddWindow( &aBtnTotalCol );
- aBtnMore.AddWindow( &aBtnTotalRow );
- aBtnMore.AddWindow( &aBtnFilter );
- aBtnMore.AddWindow( &aBtnDrillDown );
- aBtnMore.SetClickHdl( LINK( this, ScDPLayoutDlg, MoreClickHdl ) );
-
- {
- Size aFieldSize( Window( this, ScResId( WND_FIELD ) ).GetSizePixel() );
- OHEIGHT = aFieldSize.Height();
- OWIDTH = aFieldSize.Width();
- }
- SSPACE = Window( this, ScResId( WND_FIELD_SPACE ) ).GetSizePixel().Width();
-
- CalcWndSizes();
-
- aSelectArr.resize( MAX_LABELS );
- aPageArr.resize( MAX_PAGEFIELDS );
- aColArr.resize( MAX_FIELDS );
- aRowArr.resize( MAX_FIELDS );
- aDataArr.resize( MAX_FIELDS );
-
- ScRange inRange;
- String inString;
- if (xDlgDPObject->GetSheetDesc())
- {
- aEdInPos.Enable();
- aRbInPos.Enable();
- aOldRange = xDlgDPObject->GetSheetDesc()->aSourceRange;
- aOldRange.Format( inString, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
- aEdInPos.SetText(inString);
+// ============================================================================
+
+ScPivotLayoutDlg::ScPivotLayoutDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, const ScDPObject& rDPObject ) :
+
+ ScAnyRefDlg( pB, pCW, pParent, RID_SCDLG_PIVOT_LAYOUT ),
+
+ maFlLayout( this, ScResId( FL_LAYOUT ) ),
+ maScrPage( this, ScResId( SCROLL_PAGE ) ),
+ maFtPage( this, ScResId( FT_PAGE ) ),
+ maWndPage( this, ScResId( WND_PAGE ), maScrPage, &maFtPage, lclGetNameWithoutMnemonic( maFtPage ), PIVOTFIELDTYPE_PAGE, HID_SC_DPLAY_PAGE, POINTER_PIVOT_FIELD, 5, 2, 1, 0 ),
+ maScrCol( this, ScResId( SCROLL_COL ) ),
+ maFtCol( this, ScResId( FT_COL ) ),
+ maWndCol( this, ScResId( WND_COL ), maScrCol, &maFtCol, lclGetNameWithoutMnemonic( maFtCol ), PIVOTFIELDTYPE_COL, HID_SC_DPLAY_COLUMN, POINTER_PIVOT_COL, 4, 2, 1, 0 ),
+ maScrRow( this, ScResId( SCROLL_ROW ) ),
+ maFtRow( this, ScResId( FT_ROW ) ),
+ maWndRow( this, ScResId( WND_ROW ), maScrRow, &maFtRow, lclGetNameWithoutMnemonic( maFtRow ), PIVOTFIELDTYPE_ROW, HID_SC_DPLAY_ROW, POINTER_PIVOT_ROW, 1, 8, 1, 0 ),
+ maScrData( this, ScResId( SCROLL_DATA ) ),
+ maFtData( this, ScResId( FT_DATA ) ),
+ maWndData( this, ScResId( WND_DATA ), maScrData, &maFtData, lclGetNameWithoutMnemonic( maFtData ), PIVOTFIELDTYPE_DATA, HID_SC_DPLAY_DATA, POINTER_PIVOT_FIELD, 1, 8, 4, 0 ),
+ maFlSelect( this, ScResId( FL_SELECT ) ),
+ maScrSelect( this, ScResId( WND_HSCROLL ) ),
+ maWndSelect( this, ScResId( WND_SELECT ), maScrSelect, 0, String( ScResId( STR_SELECT ) ), PIVOTFIELDTYPE_SELECT, HID_SC_DPLAY_SELECT, POINTER_PIVOT_FIELD, 2, 10, 1, 2 ),
+ maFtInfo( this, ScResId( FT_INFO ) ),
+
+ maFlAreas( this, ScResId( FL_OUTPUT ) ),
+ maFtInArea( this, ScResId( FT_INAREA) ),
+ maEdInPos( this, ScResId( ED_INAREA) ),
+ maRbInPos( this, ScResId( RB_INAREA ), &maEdInPos, this ),
+ maLbOutPos( this, ScResId( LB_OUTAREA ) ),
+ maFtOutArea( this, ScResId( FT_OUTAREA ) ),
+ maEdOutPos( this, this, ScResId( ED_OUTAREA ) ),
+ maRbOutPos( this, ScResId( RB_OUTAREA ), &maEdOutPos, this ),
+ maBtnIgnEmptyRows( this, ScResId( BTN_IGNEMPTYROWS ) ),
+ maBtnDetectCat( this, ScResId( BTN_DETECTCAT ) ),
+ maBtnTotalCol( this, ScResId( BTN_TOTALCOL ) ),
+ maBtnTotalRow( this, ScResId( BTN_TOTALROW ) ),
+ maBtnFilter( this, ScResId( BTN_FILTER ) ),
+ maBtnDrillDown( this, ScResId( BTN_DRILLDOWN ) ),
+
+ maBtnOk( this, ScResId( BTN_OK ) ),
+ maBtnCancel( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp( this, ScResId( BTN_HELP ) ),
+ maBtnRemove( this, ScResId( BTN_REMOVE ) ),
+ maBtnOptions( this, ScResId( BTN_OPTIONS ) ),
+ maBtnMore( this, ScResId( BTN_MORE ) ),
+
+ mxDlgDPObject( new ScDPObject( rDPObject ) ),
+ mpViewData( ((ScTabViewShell*)SfxViewShell::Current())->GetViewData() ),
+ mpDoc( ((ScTabViewShell*)SfxViewShell::Current())->GetViewData()->GetDocument() ),
+ mpFocusWindow( 0 ),
+ mpTrackingWindow( 0 ),
+ mpDropWindow( 0 ),
+ mpActiveEdit( 0 ),
+ mbRefInputMode( false )
+{
+ DBG_ASSERT( mpViewData && mpDoc, "ScPivotLayoutDlg::ScPivotLayoutDlg - missing document or view data" );
+
+ mxDlgDPObject->SetAlive( true ); // needed to get structure information
+ mxDlgDPObject->FillOldParam( maPivotData );
+ mxDlgDPObject->FillLabelData( maPivotData );
+
+ maBtnRemove.SetClickHdl( LINK( this, ScPivotLayoutDlg, ClickHdl ) );
+ maBtnOptions.SetClickHdl( LINK( this, ScPivotLayoutDlg, ClickHdl ) );
+
+ // PIVOT_MAXFUNC defined in sc/inc/dpglobal.hxx
+ maFuncNames.reserve( PIVOT_MAXFUNC );
+ for( sal_uInt16 i = 1; i <= PIVOT_MAXFUNC; ++i )
+ maFuncNames.push_back( String( ScResId( i ) ) );
+
+ maBtnMore.AddWindow( &maFlAreas );
+ maBtnMore.AddWindow( &maFtInArea );
+ maBtnMore.AddWindow( &maEdInPos );
+ maBtnMore.AddWindow( &maRbInPos );
+ maBtnMore.AddWindow( &maFtOutArea );
+ maBtnMore.AddWindow( &maLbOutPos );
+ maBtnMore.AddWindow( &maEdOutPos );
+ maBtnMore.AddWindow( &maRbOutPos );
+ maBtnMore.AddWindow( &maBtnIgnEmptyRows );
+ maBtnMore.AddWindow( &maBtnDetectCat );
+ maBtnMore.AddWindow( &maBtnTotalCol );
+ maBtnMore.AddWindow( &maBtnTotalRow );
+ maBtnMore.AddWindow( &maBtnFilter );
+ maBtnMore.AddWindow( &maBtnDrillDown );
+ maBtnMore.SetClickHdl( LINK( this, ScPivotLayoutDlg, MoreClickHdl ) );
+
+ if( mxDlgDPObject->GetSheetDesc() )
+ {
+ maEdInPos.Enable();
+ maRbInPos.Enable();
+ ScRange aRange = mxDlgDPObject->GetSheetDesc()->aSourceRange;
+ String aString;
+ aRange.Format( aString, SCR_ABS_3D, mpDoc, mpDoc->GetAddressConvention() );
+ maEdInPos.SetText( aString );
}
else
{
- /* Data is not reachable, so could be a remote database */
- aEdInPos.Disable();
- aRbInPos.Disable();
+ // data is not reachable, so could be a remote database
+ maEdInPos.Disable();
+ maRbInPos.Disable();
}
- InitFields();
+ // #i29203# align right border of page window with data window
+ long nPagePosX = maWndData.GetPosPixel().X() + maWndData.GetSizePixel().Width() - maWndPage.GetSizePixel().Width();
+ maWndPage.SetPosPixel( Point( nPagePosX, maWndPage.GetPosPixel().Y() ) );
+ maScrPage.SetPosPixel( Point( maScrData.GetPosPixel().X(), maScrPage.GetPosPixel().Y() ) );
+
+ InitFieldWindows();
- aLbOutPos .SetSelectHdl( LINK( this, ScDPLayoutDlg, SelAreaHdl ) );
- aEdOutPos .SetModifyHdl( LINK( this, ScDPLayoutDlg, EdModifyHdl ) );
- aEdInPos .SetModifyHdl( LINK( this, ScDPLayoutDlg, EdInModifyHdl ) );
- aBtnOk .SetClickHdl ( LINK( this, ScDPLayoutDlg, OkHdl ) );
- aBtnCancel.SetClickHdl ( LINK( this, ScDPLayoutDlg, CancelHdl ) );
- Link aLink = LINK( this, ScDPLayoutDlg, GetFocusHdl );
- if ( aEdInPos.IsEnabled() )
- // Once disabled it will never get enabled, so no need to handle focus.
- aEdInPos.SetGetFocusHdl( aLink );
- aEdOutPos.SetGetFocusHdl( aLink );
+ maLbOutPos.SetSelectHdl( LINK( this, ScPivotLayoutDlg, SelAreaHdl ) );
+ maEdOutPos.SetModifyHdl( LINK( this, ScPivotLayoutDlg, EdOutModifyHdl ) );
+ maEdInPos.SetModifyHdl( LINK( this, ScPivotLayoutDlg, EdInModifyHdl ) );
+ maBtnOk.SetClickHdl( LINK( this, ScPivotLayoutDlg, OkHdl ) );
+ maBtnCancel.SetClickHdl( LINK( this, ScPivotLayoutDlg, CancelHdl ) );
- if ( pViewData && pDoc )
+ if( mpViewData && mpDoc )
{
/*
* Aus den RangeNames des Dokumentes werden nun die
@@ -281,11 +195,11 @@ void __EXPORT ScDPLayoutDlg::Init()
* um sinnvolle Bereiche handelt
*/
- aLbOutPos.Clear();
- aLbOutPos.InsertEntry( aStrUndefined, 0 );
- aLbOutPos.InsertEntry( aStrNewTable, 1 );
+ maLbOutPos.Clear();
+ maLbOutPos.InsertEntry( String( ScResId( SCSTR_UNDEFINED ) ), 0 );
+ maLbOutPos.InsertEntry( String( ScResId( SCSTR_NEWTABLE ) ), 1 );
- ScAreaNameIterator aIter( pDoc );
+ ScAreaNameIterator aIter( mpDoc );
String aName;
ScRange aRange;
String aRefStr;
@@ -293,1531 +207,742 @@ void __EXPORT ScDPLayoutDlg::Init()
{
if ( !aIter.WasDBName() ) // hier keine DB-Bereiche !
{
- sal_uInt16 nInsert = aLbOutPos.InsertEntry( aName );
+ sal_uInt16 nInsert = maLbOutPos.InsertEntry( aName );
- aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention() );
- aLbOutPos.SetEntryData( nInsert, new String( aRefStr ) );
+ aRange.aStart.Format( aRefStr, SCA_ABS_3D, mpDoc, mpDoc->GetAddressConvention() );
+ maLbOutPos.SetEntryData( nInsert, new String( aRefStr ) );
}
}
}
- if ( thePivotData.nTab != MAXTAB+1 )
+ if ( maPivotData.nTab != MAXTAB+1 )
{
String aStr;
- ScAddress( thePivotData.nCol,
- thePivotData.nRow,
- thePivotData.nTab ).Format( aStr, STD_FORMAT, pDoc, pDoc->GetAddressConvention() );
- aEdOutPos.SetText( aStr );
- EdModifyHdl(0);
+ ScAddress( maPivotData.nCol,
+ maPivotData.nRow,
+ maPivotData.nTab ).Format( aStr, STD_FORMAT, mpDoc, mpDoc->GetAddressConvention() );
+ maEdOutPos.SetText( aStr );
+ EdOutModifyHdl( 0 );
}
else
{
- aLbOutPos.SelectEntryPos( aLbOutPos.GetEntryCount()-1 );
+ maLbOutPos.SelectEntryPos( maLbOutPos.GetEntryCount()-1 );
SelAreaHdl(NULL);
}
- aBtnIgnEmptyRows.Check( thePivotData.bIgnoreEmptyRows );
- aBtnDetectCat .Check( thePivotData.bDetectCategories );
- aBtnTotalCol .Check( thePivotData.bMakeTotalCol );
- aBtnTotalRow .Check( thePivotData.bMakeTotalRow );
-
- if( const ScDPSaveData* pSaveData = xDlgDPObject->GetSaveData() )
- {
- aBtnFilter.Check( pSaveData->GetFilterButton() );
- aBtnDrillDown.Check( pSaveData->GetDrillDown() );
- }
- else
- {
- aBtnFilter.Check();
- aBtnDrillDown.Check();
- }
-
- aWndPage.SetHelpId( HID_SC_DPLAY_PAGE );
- aWndCol.SetHelpId( HID_SC_DPLAY_COLUMN );
- aWndRow.SetHelpId( HID_SC_DPLAY_ROW );
- aWndData.SetHelpId( HID_SC_DPLAY_DATA );
- aWndSelect.SetHelpId( HID_SC_DPLAY_SELECT );
-
- InitFocus();
+ maBtnIgnEmptyRows.Check( maPivotData.bIgnoreEmptyRows );
+ maBtnDetectCat.Check( maPivotData.bDetectCategories );
+ maBtnTotalCol.Check( maPivotData.bMakeTotalCol );
+ maBtnTotalRow.Check( maPivotData.bMakeTotalRow );
-// SetDispatcherLock( sal_True ); // Modal-Modus einschalten
-
- //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
- //SFX_APPWINDOW->Disable(sal_False); //! allgemeine Methode im ScAnyRefDlg
-}
+ const ScDPSaveData* pSaveData = mxDlgDPObject->GetSaveData();
+ maBtnFilter.Check( !pSaveData || pSaveData->GetFilterButton() );
+ maBtnDrillDown.Check( !pSaveData || pSaveData->GetDrillDown() );
+ // child event listener handles field movement when keyboard shortcut is pressed
+ AddChildEventListener( LINK( this, ScPivotLayoutDlg, ChildEventListener ) );
+ GrabFieldFocus( maWndSelect );
-//----------------------------------------------------------------------------
-
-sal_Bool __EXPORT ScDPLayoutDlg::Close()
-{
- return DoClose( ScPivotLayoutWrapper::GetChildWindowId() );
+ FreeResource();
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::StateChanged( StateChangedType nStateChange )
+ScPivotLayoutDlg::~ScPivotLayoutDlg()
{
- ScAnyRefDlg::StateChanged( nStateChange );
+ RemoveChildEventListener( LINK( this, ScPivotLayoutDlg, ChildEventListener ) );
- if ( nStateChange == STATE_CHANGE_INITSHOW )
- {
- // #124828# Hiding the FixedTexts and clearing the tab stop style bits
- // has to be done after assigning the mnemonics, but Paint is too late,
- // because the test tool may send key events to the dialog when it isn't visible.
- // Mnemonics are assigned in the Dialog::StateChanged for STATE_CHANGE_INITSHOW,
- // so this can be done immediately afterwards.
-
- aWndPage.UseMnemonic();
- aWndCol.UseMnemonic();
- aWndRow.UseMnemonic();
- aWndData.UseMnemonic();
- }
+ for( sal_uInt16 i = 2, nEntries = maLbOutPos.GetEntryCount(); i < nEntries; ++i )
+ delete (String*)maLbOutPos.GetEntryData( i );
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
+ScDPLabelData* ScPivotLayoutDlg::GetLabelData( SCCOL nCol, size_t* pnIndex )
{
- size_t nLabelCount = rLabels.size();
- if (nLabelCount > MAX_LABELS)
- nLabelCount = MAX_LABELS;
- size_t nLast = (nLabelCount > PAGE_SIZE) ? (PAGE_SIZE - 1) : (nLabelCount - 1);
-
- aLabelDataArr.clear();
- aLabelDataArr.reserve( nLabelCount );
- for ( size_t i=0; i < nLabelCount; i++ )
+ ScDPLabelData* pLabelData = 0;
+ for( ScDPLabelDataVector::iterator aIt = maLabelData.begin(), aEnd = maLabelData.end(); !pLabelData && (aIt != aEnd); ++aIt )
{
- aLabelDataArr.push_back(*rLabels[i]);
-
- if ( i <= nLast )
+ if( aIt->mnCol == nCol )
{
- aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
- aSelectArr[i].reset( new ScDPFuncData( aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask ) );
+ pLabelData = &*aIt;
+ if( pnIndex )
+ *pnIndex = aIt - maLabelData.begin();
}
}
+ return pLabelData;
}
-
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::InitWnd( PivotField* pArr, long nCount, ScDPFieldType eType )
+String ScPivotLayoutDlg::GetFuncString( sal_uInt16& rnFuncMask, bool bIsValue )
{
- if ( pArr && (eType != TYPE_SELECT) )
- {
- ScDPFuncDataVec* pInitArr = NULL;
- ScDPFieldWindow* pInitWnd = NULL;
- sal_Bool bDataArr = sal_False;
+ String aStr;
- switch ( eType )
+ if( (rnFuncMask == PIVOT_FUNC_NONE) || (rnFuncMask == PIVOT_FUNC_AUTO) )
+ {
+ if( bIsValue )
{
- case TYPE_PAGE:
- pInitArr = &aPageArr;
- pInitWnd = &aWndPage;
- break;
-
- case TYPE_COL:
- pInitArr = &aColArr;
- pInitWnd = &aWndCol;
- break;
-
- case TYPE_ROW:
- pInitArr = &aRowArr;
- pInitWnd = &aWndRow;
- break;
-
- case TYPE_DATA:
- pInitArr = &aDataArr;
- pInitWnd = &aWndData;
- bDataArr = sal_True;
- break;
- default:
- break;
+ aStr = GetFuncName( PIVOTSTR_SUM );
+ rnFuncMask = PIVOT_FUNC_SUM;
}
-
- if ( pInitArr && pInitWnd )
+ else
{
- long j=0;
- for ( long i=0; (i<nCount); i++ )
- {
- SCCOL nCol = pArr[i].nCol;
- sal_uInt16 nMask = pArr[i].nFuncMask;
-
- if ( nCol != PIVOT_DATA_FIELD )
- {
- (*pInitArr)[j].reset( new ScDPFuncData( nCol, nMask, pArr[i].maFieldRef ) );
-
- if ( !bDataArr )
- {
- pInitWnd->AddField( GetLabelString( nCol ), j );
- }
- else
- {
- ScDPLabelData* pData = GetLabelData( nCol );
- DBG_ASSERT( pData, "ScDPLabelData not found" );
- if (pData)
- {
- String aStr( GetFuncString( (*pInitArr)[j]->mnFuncMask,
- pData->mbIsValue ) );
-
- aStr += GetLabelString( nCol );
- pInitWnd->AddField( aStr, j );
-
- pData->mnFuncMask = nMask;
- }
- }
- ++j;
- }
- }
-// Do not redraw here -> first the FixedText has to get its mnemonic char
-// pInitWnd->Redraw();
- }
+ aStr = GetFuncName( PIVOTSTR_COUNT );
+ rnFuncMask = PIVOT_FUNC_COUNT;
+ }
+ }
+ else if( rnFuncMask == PIVOT_FUNC_SUM ) aStr = GetFuncName( PIVOTSTR_SUM );
+ else if( rnFuncMask == PIVOT_FUNC_COUNT ) aStr = GetFuncName( PIVOTSTR_COUNT );
+ else if( rnFuncMask == PIVOT_FUNC_AVERAGE ) aStr = GetFuncName( PIVOTSTR_AVG );
+ else if( rnFuncMask == PIVOT_FUNC_MAX ) aStr = GetFuncName( PIVOTSTR_MAX );
+ else if( rnFuncMask == PIVOT_FUNC_MIN ) aStr = GetFuncName( PIVOTSTR_MIN );
+ else if( rnFuncMask == PIVOT_FUNC_PRODUCT ) aStr = GetFuncName( PIVOTSTR_PROD );
+ else if( rnFuncMask == PIVOT_FUNC_COUNT_NUM ) aStr = GetFuncName( PIVOTSTR_COUNT2 );
+ else if( rnFuncMask == PIVOT_FUNC_STD_DEV ) aStr = GetFuncName( PIVOTSTR_DEV );
+ else if( rnFuncMask == PIVOT_FUNC_STD_DEVP ) aStr = GetFuncName( PIVOTSTR_DEV2 );
+ else if( rnFuncMask == PIVOT_FUNC_STD_VAR ) aStr = GetFuncName( PIVOTSTR_VAR );
+ else if( rnFuncMask == PIVOT_FUNC_STD_VARP ) aStr = GetFuncName( PIVOTSTR_VAR2 );
+ else
+ {
+ aStr = ScGlobal::GetRscString( STR_TABLE_ERGEBNIS );
+ aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ) );
}
-}
+ return aStr;
+}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::InitFocus()
+void ScPivotLayoutDlg::NotifyStartTracking( ScPivotFieldWindow& rSourceWindow )
{
- if( aWndSelect.IsEmpty() )
- {
- aBtnOk.GrabFocus();
- NotifyFieldFocus( TYPE_SELECT, sal_False );
- }
- else
- aWndSelect.GrabFocus();
+ mpTrackingWindow = &rSourceWindow;
+ mpDropWindow = 0;
+ rSourceWindow.NotifyStartTracking();
+ StartTracking( STARTTRACK_BUTTONREPEAT );
+ SetPointer( Pointer( rSourceWindow.GetDropPointerStyle() ) );
}
-void ScDPLayoutDlg::InitFields()
+void ScPivotLayoutDlg::NotifyDoubleClick( ScPivotFieldWindow& rSourceWindow )
{
- InitWndSelect(thePivotData.maLabelArray);
- InitWnd( thePivotData.aPageArr, static_cast<long>(thePivotData.nPageCount), TYPE_PAGE );
- InitWnd( thePivotData.aColArr, static_cast<long>(thePivotData.nColCount), TYPE_COL );
- InitWnd( thePivotData.aRowArr, static_cast<long>(thePivotData.nRowCount), TYPE_ROW );
- InitWnd( thePivotData.aDataArr, static_cast<long>(thePivotData.nDataCount), TYPE_DATA );
-
- size_t nLabels = thePivotData.maLabelArray.size();
- aSlider.SetPageSize( PAGE_SIZE );
- aSlider.SetVisibleSize( PAGE_SIZE );
- aSlider.SetLineSize( LINE_SIZE );
- aSlider.SetRange( Range( 0, static_cast<long>(((nLabels+LINE_SIZE-1)/LINE_SIZE)*LINE_SIZE) ) );
-
- if ( nLabels > PAGE_SIZE )
- {
- aSlider.SetEndScrollHdl( LINK( this, ScDPLayoutDlg, ScrollHdl ) );
- aSlider.Show();
- }
- else
- aSlider.Hide();
-}
+ // nothing to do on double-click in selection window
+ if( rSourceWindow.GetType() == PIVOTFIELDTYPE_SELECT )
+ return;
-//----------------------------------------------------------------------------
+ const ScPivotFuncData* pFuncData = rSourceWindow.GetSelectedFuncData();
+ DBG_ASSERT( pFuncData, "ScPivotLayoutDlg::NotifyDoubleClick - invalid selection" );
+ if( !pFuncData )
+ return;
-void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos )
-{
- ScDPFuncData fData( *(aSelectArr[nFromIndex]) );
- size_t nAt = 0;
- ScDPFieldWindow* toWnd = NULL;
- ScDPFieldWindow* rmWnd1 = NULL;
- ScDPFieldWindow* rmWnd2 = NULL;
- ScDPFuncDataVec* toArr = NULL;
- ScDPFuncDataVec* rmArr1 = NULL;
- ScDPFuncDataVec* rmArr2 = NULL;
- sal_Bool bDataArr = sal_False;
-
- switch ( eToType )
+ ScDPLabelData* pLabelData = GetLabelData( pFuncData->mnCol );
+ DBG_ASSERT( pLabelData, "ScPivotLayoutDlg::NotifyDoubleClick - missing label data" );
+ if( !pLabelData )
+ return;
+
+ ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create();
+ DBG_ASSERT( pFactory, "ScPivotLayoutDlg::NotifyDoubleClick - ScAbstractDialogFactory creation failed" );
+ if( !pFactory )
+ return;
+
+ if( rSourceWindow.GetType() == PIVOTFIELDTYPE_DATA )
{
- case TYPE_PAGE:
- toWnd = &aWndPage;
- rmWnd1 = &aWndRow;
- rmWnd2 = &aWndCol;
- toArr = &aPageArr;
- rmArr1 = &aRowArr;
- rmArr2 = &aColArr;
- break;
-
- case TYPE_COL:
- toWnd = &aWndCol;
- rmWnd1 = &aWndPage;
- rmWnd2 = &aWndRow;
- toArr = &aColArr;
- rmArr1 = &aPageArr;
- rmArr2 = &aRowArr;
- break;
-
- case TYPE_ROW:
- toWnd = &aWndRow;
- rmWnd1 = &aWndPage;
- rmWnd2 = &aWndCol;
- toArr = &aRowArr;
- rmArr1 = &aPageArr;
- rmArr2 = &aColArr;
- break;
-
- case TYPE_DATA:
- toWnd = &aWndData;
- toArr = &aDataArr;
- bDataArr = sal_True;
- break;
-
- default:
+ ::std::auto_ptr< AbstractScDPFunctionDlg > xDlg( pFactory->CreateScDPFunctionDlg(
+ this, RID_SCDLG_DPDATAFIELD, maLabelData, *pLabelData, *pFuncData ) );
+ if( xDlg->Execute() == RET_OK )
{
- // added to avoid warnings
+ ScPivotFuncData aFuncData( *pFuncData );
+ aFuncData.mnFuncMask = pLabelData->mnFuncMask = xDlg->GetFuncMask();
+ aFuncData.maFieldRef = xDlg->GetFieldRef();
+ rSourceWindow.ModifySelectedField( aFuncData );
}
}
-
- bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
- if ( bAllowed
- && (toArr->back().get() == NULL)
- && (!Contains( toArr, fData.mnCol, nAt )) )
+ else
{
- // ggF. in anderem Fenster entfernen
- if ( rmArr1 )
- {
- if ( Contains( rmArr1, fData.mnCol, nAt ) )
- {
- rmWnd1->DelField( nAt );
- Remove( rmArr1, nAt );
- }
- }
- if ( rmArr2 )
- {
- if ( Contains( rmArr2, fData.mnCol, nAt ) )
- {
- rmWnd2->DelField( nAt );
- Remove( rmArr2, nAt );
- }
- }
+ // list of plain names of all data fields
+ ScDPNameVec aDataFieldNames;
+ maWndData.WriteFieldNames( aDataFieldNames );
+ // allow to modify layout options for row fields, if multiple data fields exist, or if it is not the last row field
+ bool bLayout = (rSourceWindow.GetType() == PIVOTFIELDTYPE_ROW) && ((aDataFieldNames.size() > 1) || (rSourceWindow.GetSelectedIndex() + 1 < rSourceWindow.GetFieldCount()));
- ScDPLabelData& rData = aLabelDataArr[nFromIndex+nOffset];
- size_t nAddedAt = 0;
-
- if ( !bDataArr )
- {
- if ( toWnd->AddField( rData.getDisplayName(),
- DlgPos2WndPos( rAtPos, *toWnd ),
- nAddedAt ) )
- {
- Insert( toArr, fData, nAddedAt );
- toWnd->GrabFocus();
- }
- }
- else
+ ::std::auto_ptr< AbstractScDPSubtotalDlg > xDlg( pFactory->CreateScDPSubtotalDlg(
+ this, RID_SCDLG_PIVOTSUBT, *mxDlgDPObject, *pLabelData, *pFuncData, aDataFieldNames, bLayout ) );
+ if( xDlg->Execute() == RET_OK )
{
- sal_uInt16 nMask = fData.mnFuncMask;
- OUString aStr = GetFuncString( nMask, rData.mbIsValue );
-
- aStr += rData.getDisplayName();
-
- if ( toWnd->AddField( aStr,
- DlgPos2WndPos( rAtPos, *toWnd ),
- nAddedAt ) )
- {
- fData.mnFuncMask = nMask;
- Insert( toArr, fData, nAddedAt );
- toWnd->GrabFocus();
- }
+ xDlg->FillLabelData( *pLabelData );
+ ScPivotFuncData aFuncData( *pFuncData );
+ aFuncData.mnFuncMask = pLabelData->mnFuncMask;
+ rSourceWindow.ModifySelectedField( aFuncData );
}
-
}
}
+void ScPivotLayoutDlg::NotifyFieldRemoved( ScPivotFieldWindow& rSourceWindow )
+{
+ // update focus: move to selection window, if source window is empty now
+ GrabFieldFocus( rSourceWindow );
+}
-//----------------------------------------------------------------------------
+// protected ------------------------------------------------------------------
-void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos )
+void ScPivotLayoutDlg::Tracking( const TrackingEvent& rTEvt )
{
- if ( eFromType == TYPE_SELECT )
- AddField( nFromIndex, eToType, rAtPos );
- else if ( eFromType != eToType )
- {
- ScDPFieldWindow* fromWnd = NULL;
- ScDPFieldWindow* toWnd = NULL;
- ScDPFieldWindow* rmWnd1 = NULL;
- ScDPFieldWindow* rmWnd2 = NULL;
- ScDPFuncDataVec* fromArr = NULL;
- ScDPFuncDataVec* toArr = NULL;
- ScDPFuncDataVec* rmArr1 = NULL;
- ScDPFuncDataVec* rmArr2 = NULL;
- size_t nAt = 0;
- sal_Bool bDataArr = sal_False;
-
- switch ( eFromType )
- {
- case TYPE_PAGE:
- fromWnd = &aWndPage;
- fromArr = &aPageArr;
- break;
-
- case TYPE_COL:
- fromWnd = &aWndCol;
- fromArr = &aColArr;
- break;
-
- case TYPE_ROW:
- fromWnd = &aWndRow;
- fromArr = &aRowArr;
- break;
-
- case TYPE_DATA:
- fromWnd = &aWndData;
- fromArr = &aDataArr;
- break;
-
- default:
- {
- // added to avoid warnings
- }
- }
+ DBG_ASSERT( mpTrackingWindow, "ScPivotLayoutDlg::Tracking - missing tracking source window" );
+ if( !mpTrackingWindow )
+ return;
- switch ( eToType )
- {
- case TYPE_PAGE:
- toWnd = &aWndPage;
- toArr = &aPageArr;
- rmWnd1 = &aWndCol;
- rmWnd2 = &aWndRow;
- rmArr1 = &aColArr;
- rmArr2 = &aRowArr;
- break;
-
- case TYPE_COL:
- toWnd = &aWndCol;
- toArr = &aColArr;
- rmWnd1 = &aWndPage;
- rmWnd2 = &aWndRow;
- rmArr1 = &aPageArr;
- rmArr2 = &aRowArr;
- break;
-
- case TYPE_ROW:
- toWnd = &aWndRow;
- toArr = &aRowArr;
- rmWnd1 = &aWndPage;
- rmWnd2 = &aWndCol;
- rmArr1 = &aPageArr;
- rmArr2 = &aColArr;
- break;
-
- case TYPE_DATA:
- toWnd = &aWndData;
- toArr = &aDataArr;
- bDataArr = sal_True;
- break;
-
- default:
- {
- // added to avoid warnings
- }
- }
+ // find target window
+ const Point& rDialogPos = rTEvt.GetMouseEvent().GetPosPixel();
+ ScPivotFieldWindow* pTargetWindow = dynamic_cast< ScPivotFieldWindow* >( FindWindow( rDialogPos ) );
- if ( fromArr && toArr && fromWnd && toWnd )
- {
- ScDPFuncData fData( *((*fromArr)[nFromIndex]) );
+ // check if the target orientation is allowed for this field
+ if( pTargetWindow && (mpTrackingWindow != pTargetWindow) && !IsInsertAllowed( *mpTrackingWindow, *pTargetWindow ) )
+ pTargetWindow = 0;
- bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
- if ( bAllowed && Contains( fromArr, fData.mnCol, nAt ) )
- {
- fromWnd->DelField( nAt );
- Remove( fromArr, nAt );
+ // tracking from selection window: do not show "delete" mouse pointer
+ PointerStyle eTargetPointer = pTargetWindow ? pTargetWindow->GetDropPointerStyle() :
+ ((mpTrackingWindow->GetType() == PIVOTFIELDTYPE_SELECT) ? POINTER_NOTALLOWED : POINTER_PIVOT_DELETE);
- if ( (toArr->back().get() == NULL)
- && (!Contains( toArr, fData.mnCol, nAt )) )
- {
- size_t nAddedAt = 0;
- if ( !bDataArr )
- {
- // ggF. in anderem Fenster entfernen
- if ( rmArr1 )
- {
- if ( Contains( rmArr1, fData.mnCol, nAt ) )
- {
- rmWnd1->DelField( nAt );
- Remove( rmArr1, nAt );
- }
- }
- if ( rmArr2 )
- {
- if ( Contains( rmArr2, fData.mnCol, nAt ) )
- {
- rmWnd2->DelField( nAt );
- Remove( rmArr2, nAt );
- }
- }
+ // after calculating pointer style, check if target is selection window
+ if( pTargetWindow && (pTargetWindow->GetType() == PIVOTFIELDTYPE_SELECT) )
+ pTargetWindow = 0;
- if ( toWnd->AddField( GetLabelString( fData.mnCol ),
- DlgPos2WndPos( rAtPos, *toWnd ),
- nAddedAt ) )
- {
- Insert( toArr, fData, nAddedAt );
- toWnd->GrabFocus();
- }
- }
- else
- {
- String aStr;
- sal_uInt16 nMask = fData.mnFuncMask;
- aStr = GetFuncString( nMask );
- aStr += GetLabelString( fData.mnCol );
-
- if ( toWnd->AddField( aStr,
- DlgPos2WndPos( rAtPos, *toWnd ),
- nAddedAt ) )
- {
- fData.mnFuncMask = nMask;
- Insert( toArr, fData, nAddedAt );
- toWnd->GrabFocus();
- }
- }
- }
- }
- }
+ // notify windows about tracking
+ if( mpDropWindow != pTargetWindow )
+ {
+ // tracking window changed
+ if( mpDropWindow )
+ mpDropWindow->NotifyEndTracking( ENDTRACKING_SUSPEND );
+ if( pTargetWindow )
+ pTargetWindow->NotifyStartTracking();
+ mpDropWindow = pTargetWindow;
}
- else // -> eFromType == eToType
+ if( mpDropWindow )
+ mpDropWindow->NotifyTracking( rDialogPos - pTargetWindow->GetPosPixel() );
+
+ // end tracking: move or remove field
+ if( rTEvt.IsTrackingEnded() )
{
- ScDPFieldWindow* theWnd = NULL;
- ScDPFuncDataVec* theArr = NULL;
- size_t nAt = 0;
- size_t nToIndex = 0;
- Point aToPos;
- sal_Bool bDataArr = sal_False;
-
- switch ( eFromType )
+ bool bCancelled = rTEvt.IsTrackingCanceled();
+ if( mpDropWindow )
{
- case TYPE_PAGE:
- theWnd = &aWndPage;
- theArr = &aPageArr;
- break;
-
- case TYPE_COL:
- theWnd = &aWndCol;
- theArr = &aColArr;
- break;
-
- case TYPE_ROW:
- theWnd = &aWndRow;
- theArr = &aRowArr;
- break;
-
- case TYPE_DATA:
- theWnd = &aWndData;
- theArr = &aDataArr;
- bDataArr = sal_True;
- break;
-
- default:
+ mpDropWindow->NotifyEndTracking( bCancelled ? ENDTRACKING_CANCEL : ENDTRACKING_DROP );
+ if( !bCancelled )
{
- // added to avoid warnings
+ size_t nInsertIndex = mpDropWindow->GetDropIndex( rDialogPos - mpDropWindow->GetPosPixel() );
+ bool bMoved = MoveField( *mpTrackingWindow, *mpDropWindow, nInsertIndex, true );
+ // focus drop window, if move was successful, otherwise back to source window
+ GrabFieldFocus( bMoved ? *mpDropWindow : *mpTrackingWindow );
}
}
-
- ScDPFuncData fData( *((*theArr)[nFromIndex]) );
-
- if ( Contains( theArr, fData.mnCol, nAt ) )
+ else
{
- aToPos = DlgPos2WndPos( rAtPos, *theWnd );
- theWnd->GetExistingIndex( aToPos, nToIndex );
-
- if ( nToIndex != nAt )
- {
- size_t nAddedAt = 0;
-
- theWnd->DelField( nAt );
- Remove( theArr, nAt );
-
- if ( !bDataArr )
- {
- if ( theWnd->AddField( GetLabelString( fData.mnCol ),
- aToPos,
- nAddedAt ) )
- {
- Insert( theArr, fData, nAddedAt );
- }
- }
- else
- {
- String aStr;
- sal_uInt16 nMask = fData.mnFuncMask;
- aStr = GetFuncString( nMask );
- aStr += GetLabelString( fData.mnCol );
-
- if ( theWnd->AddField( aStr,
- DlgPos2WndPos( rAtPos, *theWnd ),
- nAddedAt ) )
- {
- fData.mnFuncMask = nMask;
- Insert( theArr, fData, nAddedAt );
- }
- }
- }
+ // drop target invalid (outside field windows): remove tracked field
+ if( !bCancelled )
+ mpTrackingWindow->RemoveSelectedField();
+ // focus source window (or another window, if it is empty now)
+ GrabFieldFocus( *mpTrackingWindow );
}
+ eTargetPointer = POINTER_ARROW;
+ if( mpTrackingWindow != mpDropWindow )
+ mpTrackingWindow->NotifyEndTracking( ENDTRACKING_CANCEL );
+ mpTrackingWindow = mpDropWindow = 0;
}
+ SetPointer( eTargetPointer );
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::RemoveField( ScDPFieldType eFromType, size_t nIndex )
+void ScPivotLayoutDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
{
- ScDPFuncDataVec* pArr = NULL;
- switch( eFromType )
+ if( !mbRefInputMode || !mpActiveEdit )
+ return;
+
+ if( rRef.aStart != rRef.aEnd )
+ RefInputStart( mpActiveEdit );
+
+ if( mpActiveEdit == &maEdInPos )
{
- case TYPE_PAGE: pArr = &aPageArr; break;
- case TYPE_COL: pArr = &aColArr; break;
- case TYPE_ROW: pArr = &aRowArr; break;
- case TYPE_DATA: pArr = &aDataArr; break;
- default:
- {
- // added to avoid warnings
- }
+ String aRefStr;
+ rRef.Format( aRefStr, SCR_ABS_3D, pDocP, pDocP->GetAddressConvention() );
+ mpActiveEdit->SetRefString( aRefStr );
}
-
- if( pArr )
+ else if( mpActiveEdit == &maEdOutPos )
{
- ScDPFieldWindow& rWnd = GetFieldWindow( eFromType );
- rWnd.DelField( nIndex );
- Remove( pArr, nIndex );
- if( rWnd.IsEmpty() ) InitFocus();
+ String aRefStr;
+ rRef.aStart.Format( aRefStr, STD_FORMAT, pDocP, pDocP->GetAddressConvention() );
+ mpActiveEdit->SetRefString( aRefStr );
}
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::NotifyMouseButtonUp( const Point& rAt )
+sal_Bool ScPivotLayoutDlg::IsRefInputMode() const
{
- if ( bIsDrag )
- {
- bIsDrag = sal_False;
-
- ScDPFieldType eDnDToType = TYPE_SELECT;
- Point aPos = ScreenToOutputPixel( rAt );
- sal_Bool bDel = sal_False;
-
- if ( aRectPage.IsInside( aPos ) )
- {
- eDnDToType = TYPE_PAGE;
- bDel = sal_False;
- }
- else if ( aRectCol.IsInside( aPos ) )
- {
- eDnDToType = TYPE_COL;
- bDel = sal_False;
- }
- else if ( aRectRow.IsInside( aPos ) )
- {
- eDnDToType = TYPE_ROW;
- bDel = sal_False;
- }
- else if ( aRectData.IsInside( aPos ) )
- {
- eDnDToType = TYPE_DATA;
- bDel = sal_False;
- }
- else if ( aRectSelect.IsInside( aPos ) )
- {
- eDnDToType = TYPE_SELECT;
- bDel = sal_True;
- }
- else
- bDel = sal_True;
-
- if ( bDel )
- RemoveField( eDnDFromType, nDnDFromIndex );
- else
- MoveField( eDnDFromType, nDnDFromIndex, eDnDToType, aPos );
- }
+ return mbRefInputMode;
}
-
-//----------------------------------------------------------------------------
-
-PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt )
+void ScPivotLayoutDlg::SetActive()
{
- PointerStyle ePtr = POINTER_ARROW;
-
- if ( bIsDrag )
+ if( mbRefInputMode )
{
- Point aPos = ScreenToOutputPixel( rAt );
- ScDPFieldType eCheckTarget = TYPE_SELECT;
-
- if ( aRectPage.IsInside( aPos ) )
- eCheckTarget = TYPE_PAGE;
- else if ( aRectCol.IsInside( aPos ) )
- eCheckTarget = TYPE_COL;
- else if ( aRectRow.IsInside( aPos ) )
- eCheckTarget = TYPE_ROW;
- else if ( aRectData.IsInside( aPos ) )
- eCheckTarget = TYPE_DATA;
- else if ( eDnDFromType != TYPE_SELECT )
- ePtr = POINTER_PIVOT_DELETE;
- else if ( aRectSelect.IsInside( aPos ) )
- ePtr = lclGetPointerForField( TYPE_SELECT );
- else
- ePtr = POINTER_NOTALLOWED;
+ if( mpActiveEdit )
+ mpActiveEdit->GrabFocus();
- if ( eCheckTarget != TYPE_SELECT )
- {
- // check if the target orientation is allowed for this field
- ScDPFuncDataVec* fromArr = NULL;
- switch ( eDnDFromType )
- {
- case TYPE_PAGE: fromArr = &aPageArr; break;
- case TYPE_COL: fromArr = &aColArr; break;
- case TYPE_ROW: fromArr = &aRowArr; break;
- case TYPE_DATA: fromArr = &aDataArr; break;
- case TYPE_SELECT: fromArr = &aSelectArr; break;
- }
- ScDPFuncData fData( *((*fromArr)[nDnDFromIndex]) );
- if (IsOrientationAllowed( fData.mnCol, eCheckTarget ))
- ePtr = lclGetPointerForField( eCheckTarget );
- else
- ePtr = POINTER_NOTALLOWED;
- }
+ if( mpActiveEdit == &maEdInPos )
+ EdInModifyHdl( 0 );
+ else if( mpActiveEdit == &maEdOutPos )
+ EdOutModifyHdl( 0 );
+ }
+ else
+ {
+ GrabFocus();
}
- return ePtr;
+ RefInputDone();
}
-
-//----------------------------------------------------------------------------
-
-PointerStyle ScDPLayoutDlg::NotifyMouseButtonDown( ScDPFieldType eType, size_t nFieldIndex )
+sal_Bool ScPivotLayoutDlg::Close()
{
- bIsDrag = sal_True;
- eDnDFromType = eType;
- nDnDFromIndex = nFieldIndex;
- return lclGetPointerForField( eType );
+ return DoClose( ScPivotLayoutWrapper::GetChildWindowId() );
}
+// private --------------------------------------------------------------------
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
+ScPivotFieldWindow& ScPivotLayoutDlg::GetFieldWindow( ScPivotFieldType eFieldType )
{
- ScDPFuncDataVec* pArr = NULL;
- switch ( eType )
+ switch( eFieldType )
{
- case TYPE_PAGE: pArr = &aPageArr; break;
- case TYPE_COL: pArr = &aColArr; break;
- case TYPE_ROW: pArr = &aRowArr; break;
- case TYPE_DATA: pArr = &aDataArr; break;
- default:
- {
- // added to avoid warnings
- }
+ case PIVOTFIELDTYPE_PAGE: return maWndPage;
+ case PIVOTFIELDTYPE_ROW: return maWndRow;
+ case PIVOTFIELDTYPE_COL: return maWndCol;
+ case PIVOTFIELDTYPE_DATA: return maWndData;
+ default:;
}
+ return maWndSelect;
+}
- if ( pArr )
+bool ScPivotLayoutDlg::IsInsertAllowed( const ScPivotFieldWindow& rSourceWindow, const ScPivotFieldWindow& rTargetWindow )
+{
+ if( rTargetWindow.GetType() != PIVOTFIELDTYPE_SELECT )
{
- if ( nFieldIndex >= pArr->size() )
+ const ScPivotFuncData* pSourceData = rSourceWindow.GetSelectedFuncData();
+ ScDPLabelData* pLabelData = pSourceData ? GetLabelData( pSourceData->mnCol ) : 0;
+ DBG_ASSERT( pLabelData, "ScPivotLayoutDlg::IsInsertAllowed - label data not found" );
+ if( pLabelData )
{
- DBG_ERROR("invalid selection");
- return;
- }
-
- size_t nArrPos = 0;
- if( ScDPLabelData* pData = GetLabelData( (*pArr)[nFieldIndex]->mnCol, &nArrPos ) )
- {
- ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
- DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
-
- switch ( eType )
+ sheet::DataPilotFieldOrientation eOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+ switch( rTargetWindow.GetType() )
{
- case TYPE_PAGE:
- case TYPE_COL:
- case TYPE_ROW:
- {
- // list of names of all data fields
- std::vector< String > aDataFieldNames;
- for( ScDPFuncDataVec::const_iterator aIt = aDataArr.begin(), aEnd = aDataArr.end();
- (aIt != aEnd) && aIt->get(); ++aIt )
- {
- String aName( GetLabelString( (*aIt)->mnCol ) );
- if( aName.Len() )
- aDataFieldNames.push_back( aName );
- }
-
- bool bLayout = (eType == TYPE_ROW) &&
- ((aDataFieldNames.size() > 1) || ((nFieldIndex + 1 < pArr->size()) && (*pArr)[nFieldIndex+1].get()));
-
- AbstractScDPSubtotalDlg* pDlg = pFact->CreateScDPSubtotalDlg(
- this, RID_SCDLG_PIVOTSUBT,
- *xDlgDPObject, *pData, *(*pArr)[nFieldIndex], aDataFieldNames, bLayout );
-
- if ( pDlg->Execute() == RET_OK )
- {
- pDlg->FillLabelData( *pData );
- (*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask;
- }
- delete pDlg;
- }
- break;
-
- case TYPE_DATA:
- {
- AbstractScDPFunctionDlg* pDlg = pFact->CreateScDPFunctionDlg(
- this, RID_SCDLG_DPDATAFIELD,
- aLabelDataArr, *pData, *(*pArr)[nFieldIndex] );
-
- if ( pDlg->Execute() == RET_OK )
- {
- (*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask = pDlg->GetFuncMask();
- (*pArr)[nFieldIndex]->maFieldRef = pDlg->GetFieldRef();
-
- String aStr( GetFuncString ( aDataArr[nFieldIndex]->mnFuncMask ) );
- aStr += GetLabelString( aDataArr[nFieldIndex]->mnCol );
- aWndData.SetFieldText( aStr, nFieldIndex );
- }
- delete pDlg;
- }
- break;
-
- default:
- {
- // added to avoid warnings
- }
+ case PIVOTFIELDTYPE_PAGE: eOrient = sheet::DataPilotFieldOrientation_PAGE; break;
+ case PIVOTFIELDTYPE_COL: eOrient = sheet::DataPilotFieldOrientation_COLUMN; break;
+ case PIVOTFIELDTYPE_ROW: eOrient = sheet::DataPilotFieldOrientation_ROW; break;
+ case PIVOTFIELDTYPE_DATA: eOrient = sheet::DataPilotFieldOrientation_DATA; break;
+ default: return false;
}
+ return ScDPObject::IsOrientationAllowed( static_cast< sal_uInt16 >( eOrient ), pLabelData->mnFlags );
}
}
+ return false;
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::NotifyFieldFocus( ScDPFieldType eType, sal_Bool bGotFocus )
+void ScPivotLayoutDlg::InitFieldWindows()
{
- /* Enable Remove/Options buttons on GetFocus in field window.
- #107616# Enable them also, if dialog is deactivated (click into document).
- The !IsActive() condition handles the case that a LoseFocus event of a
- field window would follow the Deactivate event of this dialog. */
- sal_Bool bEnable = (bGotFocus || !IsActive()) && (eType != TYPE_SELECT);
-
- // #128113# The TestTool may set the focus into an empty field.
- // Then the Remove/Options buttons must be disabled.
- if ( bEnable && bGotFocus && GetFieldWindow( eType ).IsEmpty() )
- bEnable = sal_False;
-
- aBtnRemove.Enable( bEnable );
- aBtnOptions.Enable( bEnable );
- if( bGotFocus )
- eLastActiveType = eType;
+ maLabelData = maPivotData.maLabelArray;
+ maWndSelect.ReadDataLabels( maLabelData );
+ maWndPage.ReadPivotFields( maPivotData.maPageArr );
+ maWndCol.ReadPivotFields( maPivotData.maColArr );
+ maWndRow.ReadPivotFields( maPivotData.maRowArr );
+ maWndData.ReadPivotFields( maPivotData.maDataArr );
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::NotifyMoveField( ScDPFieldType eToType )
+void ScPivotLayoutDlg::GrabFieldFocus( ScPivotFieldWindow& rFieldWindow )
{
- ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
- if( (eToType != TYPE_SELECT) && !rWnd.IsEmpty() )
+ if( rFieldWindow.IsEmpty() )
{
- MoveField( eLastActiveType, rWnd.GetSelectedField(), eToType, GetFieldWindow( eToType ).GetLastPosition() );
- if( rWnd.IsEmpty() )
- NotifyFieldFocus( eToType, sal_True );
+ if( maWndSelect.IsEmpty() )
+ maBtnOk.GrabFocus();
else
- rWnd.GrabFocus();
- if( eLastActiveType == TYPE_SELECT )
- aWndSelect.SelectNext();
+ maWndSelect.GrabFocus();
}
else
- InitFocus();
+ rFieldWindow.GrabFocus();
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::NotifyRemoveField( ScDPFieldType eType, size_t nFieldIndex )
-{
- if( eType != TYPE_SELECT )
- RemoveField( eType, nFieldIndex );
-}
-
-//----------------------------------------------------------------------------
+namespace {
-sal_Bool ScDPLayoutDlg::NotifyMoveSlider( sal_uInt16 nKeyCode )
+void lclFindFieldWindow( ScPivotFieldWindow*& rpFieldWindow, const ScPivotFuncData*& rpFuncData, size_t& rnFieldIndex, ScPivotFieldWindow& rFieldWindow )
{
- long nOldPos = aSlider.GetThumbPos();
- switch( nKeyCode )
+ ScPivotFuncDataEntry aEntry = rFieldWindow.FindFuncDataByCol( rpFuncData->mnCol );
+ if( aEntry.first )
{
- case KEY_HOME: aSlider.DoScroll( 0 ); break;
- case KEY_END: aSlider.DoScroll( aSlider.GetRangeMax() ); break;
- case KEY_UP:
- case KEY_LEFT: aSlider.DoScrollAction( SCROLL_LINEUP ); break;
- case KEY_DOWN:
- case KEY_RIGHT: aSlider.DoScrollAction( SCROLL_LINEDOWN ); break;
+ rpFieldWindow = &rFieldWindow;
+ rpFuncData = aEntry.first;
+ rnFieldIndex = aEntry.second;
}
- return nOldPos != aSlider.GetThumbPos();
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::Deactivate()
-{
- /* #107616# If the dialog has been deactivated (click into document), the LoseFocus
- event from field window disables Remove/Options buttons. Re-enable them here by
- simulating a GetFocus event. Event order of LoseFocus and Deactivate is not important.
- The last event will enable the buttons in both cases (see NotifyFieldFocus). */
- NotifyFieldFocus( eLastActiveType, sal_True );
-}
-
-//----------------------------------------------------------------------------
+} // namespace
-sal_Bool ScDPLayoutDlg::Contains( ScDPFuncDataVec* pArr, SCsCOL nCol, size_t& nAt )
+bool ScPivotLayoutDlg::MoveField( ScPivotFieldWindow& rSourceWindow, ScPivotFieldWindow& rTargetWindow, size_t nInsertIndex, bool bMoveExisting )
{
- if ( !pArr )
- return sal_False;
-
- sal_Bool bFound = sal_False;
- size_t i = 0;
+ // move inside the same window
+ if( &rSourceWindow == &rTargetWindow )
+ return bMoveExisting && rTargetWindow.MoveSelectedField( nInsertIndex );
- while ( (i<pArr->size()) && ((*pArr)[i].get() != NULL) && !bFound )
+ // do not insert if not supported by target window
+ if( !IsInsertAllowed( rSourceWindow, rTargetWindow ) )
{
- bFound = ((*pArr)[i]->mnCol == nCol);
- if ( bFound )
- nAt = i;
- i++;
+ rSourceWindow.RemoveSelectedField();
+ return false;
}
- return bFound;
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::Remove( ScDPFuncDataVec* pArr, size_t nAt )
-{
- if ( !pArr || (nAt>=pArr->size()) )
- return;
-
- pArr->erase( pArr->begin() + nAt );
- pArr->push_back( ScDPFuncDataRef() );
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::Insert( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, size_t nAt )
-{
- if ( !pArr || (nAt>=pArr->size()) )
- return;
-
- if ( (*pArr)[nAt].get() == NULL )
- {
- (*pArr)[nAt].reset( new ScDPFuncData( rFData ) );
- }
- else
+ // move from one window to another window
+ if( const ScPivotFuncData* pSourceData = rSourceWindow.GetSelectedFuncData() )
{
- if ( pArr->back().get() == NULL ) // mind. ein Slot frei?
+ // move to page/col/row window: try to find existing field in another window
+ ScPivotFieldWindow* pSourceWindow = &rSourceWindow;
+ size_t nSourceIndex = rSourceWindow.GetSelectedIndex();
+ if( rTargetWindow.GetType() != PIVOTFIELDTYPE_DATA )
{
- pArr->insert( pArr->begin() + nAt, ScDPFuncDataRef( new ScDPFuncData( rFData ) ) );
- pArr->erase( pArr->end() - 1 );
+ lclFindFieldWindow( pSourceWindow, pSourceData, nSourceIndex, maWndPage );
+ lclFindFieldWindow( pSourceWindow, pSourceData, nSourceIndex, maWndCol );
+ lclFindFieldWindow( pSourceWindow, pSourceData, nSourceIndex, maWndRow );
}
- }
-}
+ // found in target window: move to new position
+ if( pSourceWindow == &rTargetWindow )
+ return bMoveExisting && pSourceWindow->MoveField( nSourceIndex, nInsertIndex );
-//----------------------------------------------------------------------------
+ // insert field into target window
+ rTargetWindow.InsertField( nInsertIndex, *pSourceData );
+ // remove field from source window
+ pSourceWindow->RemoveField( nSourceIndex );
+ // remove field from data window, if it is the original source
+ if( (rSourceWindow.GetType() == PIVOTFIELDTYPE_DATA) && (pSourceWindow->GetType() != PIVOTFIELDTYPE_DATA) )
+ rSourceWindow.RemoveSelectedField();
-ScDPLabelData* ScDPLayoutDlg::GetLabelData( SCsCOL nCol, size_t* pnPos )
-{
- ScDPLabelData* pData = 0;
- for( ScDPLabelDataVec::iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); !pData && (aIt != aEnd); ++aIt )
- {
- if( aIt->mnCol == nCol )
- {
- pData = &*aIt;
- if( pnPos ) *pnPos = aIt - aLabelDataArr.begin();
- }
+ return true;
}
- return pData;
-}
-
-//----------------------------------------------------------------------------
-
-String ScDPLayoutDlg::GetLabelString( SCsCOL nCol )
-{
- ScDPLabelData* pData = GetLabelData( nCol );
- DBG_ASSERT( pData, "LabelData not found" );
- if (pData)
- return pData->getDisplayName();
- return String();
+ return false;
}
-//----------------------------------------------------------------------------
+// handlers -------------------------------------------------------------------
-bool ScDPLayoutDlg::IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType )
+IMPL_LINK( ScPivotLayoutDlg, ClickHdl, PushButton *, pBtn )
{
- bool bAllowed = true;
- ScDPLabelData* pData = GetLabelData( nCol );
- DBG_ASSERT( pData, "LabelData not found" );
- if (pData)
+ if( mpFocusWindow )
{
- sheet::DataPilotFieldOrientation eOrient = sheet::DataPilotFieldOrientation_HIDDEN;
- switch (eType)
- {
- case TYPE_PAGE: eOrient = sheet::DataPilotFieldOrientation_PAGE; break;
- case TYPE_COL: eOrient = sheet::DataPilotFieldOrientation_COLUMN; break;
- case TYPE_ROW: eOrient = sheet::DataPilotFieldOrientation_ROW; break;
- case TYPE_DATA: eOrient = sheet::DataPilotFieldOrientation_DATA; break;
- case TYPE_SELECT: eOrient = sheet::DataPilotFieldOrientation_HIDDEN; break;
- }
- bAllowed = ScDPObject::IsOrientationAllowed( (sal_uInt16)eOrient, pData->mnFlags );
- }
- return bAllowed;
-}
-
-//----------------------------------------------------------------------------
-
-String ScDPLayoutDlg::GetFuncString( sal_uInt16& rFuncMask, sal_Bool bIsValue )
-{
- String aStr;
+ /* Raising sub dialogs (from the NotifyDoubleClick function) triggers
+ VCL child window focus events from this sub dialog which may
+ invalidate the member mpFocusWindow pointing to the target field
+ window. This would cause a crash with the following call to the
+ GrabFieldFocus function, if mpFocusWindow is used directly. */
+ ScPivotFieldWindow& rTargetWindow = *mpFocusWindow;
- if ( rFuncMask == PIVOT_FUNC_NONE
- || rFuncMask == PIVOT_FUNC_AUTO )
- {
- if ( bIsValue )
+ if( pBtn == &maBtnRemove )
{
- aStr = FSTR(PIVOTSTR_SUM);
- rFuncMask = PIVOT_FUNC_SUM;
+ rTargetWindow.RemoveSelectedField();
+ // focus back to field window
+ GrabFieldFocus( rTargetWindow );
}
- else
+ else if( pBtn == &maBtnOptions )
{
- aStr = FSTR(PIVOTSTR_COUNT);
- rFuncMask = PIVOT_FUNC_COUNT;
+ NotifyDoubleClick( rTargetWindow );
+ // focus back to field window
+ GrabFieldFocus( rTargetWindow );
}
}
- else if ( rFuncMask == PIVOT_FUNC_SUM ) aStr = FSTR(PIVOTSTR_SUM);
- else if ( rFuncMask == PIVOT_FUNC_COUNT ) aStr = FSTR(PIVOTSTR_COUNT);
- else if ( rFuncMask == PIVOT_FUNC_AVERAGE ) aStr = FSTR(PIVOTSTR_AVG);
- else if ( rFuncMask == PIVOT_FUNC_MAX ) aStr = FSTR(PIVOTSTR_MAX);
- else if ( rFuncMask == PIVOT_FUNC_MIN ) aStr = FSTR(PIVOTSTR_MIN);
- else if ( rFuncMask == PIVOT_FUNC_PRODUCT ) aStr = FSTR(PIVOTSTR_PROD);
- else if ( rFuncMask == PIVOT_FUNC_COUNT_NUM ) aStr = FSTR(PIVOTSTR_COUNT2);
- else if ( rFuncMask == PIVOT_FUNC_STD_DEV ) aStr = FSTR(PIVOTSTR_DEV);
- else if ( rFuncMask == PIVOT_FUNC_STD_DEVP ) aStr = FSTR(PIVOTSTR_DEV2);
- else if ( rFuncMask == PIVOT_FUNC_STD_VAR ) aStr = FSTR(PIVOTSTR_VAR);
- else if ( rFuncMask == PIVOT_FUNC_STD_VARP ) aStr = FSTR(PIVOTSTR_VAR2);
- else
- {
- aStr = ScGlobal::GetRscString( STR_TABLE_ERGEBNIS );
- aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " ));
- }
-
- return aStr;
-}
-
-
-//----------------------------------------------------------------------------
-
-Point ScDPLayoutDlg::DlgPos2WndPos( const Point& rPt, Window& rWnd )
-{
- Point aWndPt( rPt );
- aWndPt.X() = rPt.X()-rWnd.GetPosPixel().X();
- aWndPt.Y() = rPt.Y()-rWnd.GetPosPixel().Y();
-
- return aWndPt;
-}
-
-
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::CalcWndSizes()
-{
- // row/column/data area sizes
- aWndPage.SetSizePixel( Size( MAX_PAGEFIELDS * OWIDTH / 2, 2 * OHEIGHT ) );
- aWndRow.SetSizePixel( Size( OWIDTH, MAX_FIELDS * OHEIGHT ) );
- aWndCol.SetSizePixel( Size( MAX_FIELDS * OWIDTH / 2, 2 * OHEIGHT ) );
- aWndData.SetSizePixel( Size( MAX_FIELDS * OWIDTH / 2, MAX_FIELDS * OHEIGHT ) );
-
- // #i29203# align right border of page window with data window
- long nDataPosX = aWndData.GetPosPixel().X() + aWndData.GetSizePixel().Width();
- aWndPage.SetPosPixel( Point( nDataPosX - aWndPage.GetSizePixel().Width(), aWndPage.GetPosPixel().Y() ) );
-
- // selection area
- aWndSelect.SetSizePixel( Size(
- 2 * OWIDTH + SSPACE, LINE_SIZE * OHEIGHT + (LINE_SIZE - 1) * SSPACE ) );
-
- // scroll bar
- Point aSliderPos( aWndSelect.GetPosPixel() );
- Size aSliderSize( aWndSelect.GetSizePixel() );
- aSliderPos.Y() += aSliderSize.Height() + SSPACE;
- aSliderSize.Height() = GetSettings().GetStyleSettings().GetScrollBarSize();
- aSlider.SetPosSizePixel( aSliderPos, aSliderSize );
-
- aRectPage = Rectangle( aWndPage.GetPosPixel(), aWndPage.GetSizePixel() );
- aRectRow = Rectangle( aWndRow.GetPosPixel(), aWndRow.GetSizePixel() );
- aRectCol = Rectangle( aWndCol.GetPosPixel(), aWndCol.GetSizePixel() );
- aRectData = Rectangle( aWndData.GetPosPixel(), aWndData.GetSizePixel() );
- aRectSelect = Rectangle( aWndSelect.GetPosPixel(), aWndSelect.GetSizePixel() );
-}
-
-
-//----------------------------------------------------------------------------
-
-sal_Bool ScDPLayoutDlg::GetPivotArrays( PivotField* pPageArr,
- PivotField* pColArr,
- PivotField* pRowArr,
- PivotField* pDataArr,
- sal_uInt16& rPageCount,
- sal_uInt16& rColCount,
- sal_uInt16& rRowCount,
- sal_uInt16& rDataCount )
-{
- sal_Bool bFit = sal_True;
- sal_uInt16 i=0;
-
- for ( i=0; (i<aDataArr.size()) && (aDataArr[i].get() != NULL ); i++ )
- lcl_FillToPivotField( pDataArr[i], *aDataArr[i] );
- rDataCount = i;
-
- for ( i=0; (i<aPageArr.size()) && (aPageArr[i].get() != NULL ); i++ )
- lcl_FillToPivotField( pPageArr[i], *aPageArr[i] );
- rPageCount = i;
-
- for ( i=0; (i<aColArr.size()) && (aColArr[i].get() != NULL ); i++ )
- lcl_FillToPivotField( pColArr[i], *aColArr[i] );
- rColCount = i;
-
- for ( i=0; (i<aRowArr.size()) && (aRowArr[i].get() != NULL ); i++ )
- lcl_FillToPivotField( pRowArr[i], *aRowArr[i] );
- rRowCount = i;
-
- if ( rRowCount < aRowArr.size() )
- pRowArr[rRowCount++].nCol = PIVOT_DATA_FIELD;
- else if ( rColCount < aColArr.size() )
- pColArr[rColCount++].nCol = PIVOT_DATA_FIELD;
- else
- bFit = sal_False; // kein Platz fuer Datenfeld
-
- return bFit;
-}
-
-void ScDPLayoutDlg::UpdateSrcRange()
-{
- String theCurPosStr = aEdInPos.GetText();
- sal_uInt16 nResult = ScRange().Parse(theCurPosStr, pDoc, pDoc->GetAddressConvention());
-
- if ( SCA_VALID != (nResult & SCA_VALID) )
- // invalid source range.
- return;
-
- ScRefAddress start, end;
- ConvertDoubleRef(pDoc, theCurPosStr, 1, start, end, pDoc->GetAddressConvention());
- ScRange aNewRange(start.GetAddress(), end.GetAddress());
- ScSheetSourceDesc inSheet = *xDlgDPObject->GetSheetDesc();
-
- if (inSheet.aSourceRange == aNewRange)
- // new range is identical to the current range. Nothing to do.
- return;
-
- ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
- inSheet.aSourceRange = aNewRange;
- xDlgDPObject->SetSheetDesc(inSheet);
- xDlgDPObject->FillOldParam( thePivotData, sal_False );
- xDlgDPObject->FillLabelData(thePivotData);
-
- pTabViewShell->SetDialogDPObject(xDlgDPObject.get());
- aLabelDataArr.clear();
- aWndSelect.ClearFields();
- aWndData.ClearFields();
- aWndRow.ClearFields();
- aWndCol.ClearFields();
- aWndPage.ClearFields();
-
- for (size_t i = 0; i < MAX_LABELS; ++i)
- aSelectArr[i].reset();
-
- for (size_t i = 0; i < MAX_FIELDS; ++i)
- {
- aRowArr[i].reset();
- aColArr[i].reset();
- aDataArr[i].reset();
- }
-
- for (size_t i = 0; i < MAX_PAGEFIELDS; ++i)
- aPageArr[i].reset();
-
- InitFields();
+ return 0;
}
-//----------------------------------------------------------------------------
-
-void ScDPLayoutDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+IMPL_LINK( ScPivotLayoutDlg, OkHdl, OKButton *, EMPTYARG )
{
- if ( !bRefInputMode || !pEditActive )
- return;
+ String aOutPosStr = maEdOutPos.GetText();
+ ScAddress aAdrDest;
+ bool bToNewTable = maLbOutPos.GetSelectEntryPos() == 1;
+ sal_uInt16 nResult = !bToNewTable ? aAdrDest.Parse( aOutPosStr, mpDoc, mpDoc->GetAddressConvention() ) : 0;
- if ( rRef.aStart != rRef.aEnd )
- RefInputStart( pEditActive );
-
- if ( pEditActive == &aEdInPos )
- {
- String aRefStr;
- rRef.Format( aRefStr, SCR_ABS_3D, pDocP, pDocP->GetAddressConvention() );
- pEditActive->SetRefString( aRefStr );
- }
- else if ( pEditActive == &aEdOutPos )
+ if( bToNewTable || ((aOutPosStr.Len() > 0) && ((nResult & SCA_VALID) == SCA_VALID)) )
{
- String aRefStr;
- rRef.aStart.Format( aRefStr, STD_FORMAT, pDocP, pDocP->GetAddressConvention() );
- pEditActive->SetRefString( aRefStr );
- }
-}
+ ScPivotFieldVector aPageFields, aColFields, aRowFields, aDataFields;
+ maWndPage.WritePivotFields( aPageFields );
+ maWndCol.WritePivotFields( aColFields );
+ maWndRow.WritePivotFields( aRowFields );
+ maWndData.WritePivotFields( aDataFields );
+ // TODO: handle data field in dialog field windows?
+ aRowFields.resize( aRowFields.size() + 1 );
+ aRowFields.back().nCol = PIVOT_DATA_FIELD;
-//----------------------------------------------------------------------------
+ ScDPSaveData* pOldSaveData = mxDlgDPObject->GetSaveData();
-void ScDPLayoutDlg::SetActive()
-{
- if ( bRefInputMode )
- {
- if ( pEditActive )
- pEditActive->GrabFocus();
+ ScRange aOutRange( aAdrDest ); // bToNewTable is passed separately
- if ( pEditActive == &aEdInPos )
- EdInModifyHdl( NULL );
- else if ( pEditActive == &aEdOutPos )
- EdModifyHdl( NULL );
- }
- else
- {
- GrabFocus();
- }
+ ScDPSaveData aSaveData;
+ aSaveData.SetIgnoreEmptyRows( maBtnIgnEmptyRows.IsChecked() );
+ aSaveData.SetRepeatIfEmpty( maBtnDetectCat.IsChecked() );
+ aSaveData.SetColumnGrand( maBtnTotalCol.IsChecked() );
+ aSaveData.SetRowGrand( maBtnTotalRow.IsChecked() );
+ aSaveData.SetFilterButton( maBtnFilter.IsChecked() );
+ aSaveData.SetDrillDown( maBtnDrillDown.IsChecked() );
- RefInputDone();
-}
+ uno::Reference< sheet::XDimensionsSupplier > xSource = mxDlgDPObject->GetSource();
-//----------------------------------------------------------------------------
-// Handler:
-//----------------------------------------------------------------------------
+ ScDPObject::ConvertOrientation( aSaveData, aPageFields, sheet::DataPilotFieldOrientation_PAGE, 0, 0, 0, xSource, false );
+ ScDPObject::ConvertOrientation( aSaveData, aColFields, sheet::DataPilotFieldOrientation_COLUMN, 0, 0, 0, xSource, false );
+ ScDPObject::ConvertOrientation( aSaveData, aRowFields, sheet::DataPilotFieldOrientation_ROW, 0, 0, 0, xSource, false );
+ ScDPObject::ConvertOrientation( aSaveData, aDataFields, sheet::DataPilotFieldOrientation_DATA, 0, 0, 0, xSource, false, &aColFields, &aRowFields, &aPageFields );
-IMPL_LINK( ScDPLayoutDlg, ClickHdl, PushButton *, pBtn )
-{
- if( pBtn == &aBtnRemove )
- {
- ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
- RemoveField( eLastActiveType, rWnd.GetSelectedField() );
- if( !rWnd.IsEmpty() ) rWnd.GrabFocus();
- }
- else if( pBtn == &aBtnOptions )
- {
- ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
- NotifyDoubleClick( eLastActiveType, rWnd.GetSelectedField() );
- rWnd.GrabFocus();
- }
- return 0;
-}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG )
-{
- String aOutPosStr( aEdOutPos.GetText() );
- ScAddress aAdrDest;
- sal_Bool bToNewTable = (aLbOutPos.GetSelectEntryPos() == 1);
- sal_uInt16 nResult = !bToNewTable ? aAdrDest.Parse( aOutPosStr, pDoc, pDoc->GetAddressConvention() ) : 0;
-
- if ( bToNewTable
- || ( (aOutPosStr.Len() > 0) && (SCA_VALID == (nResult & SCA_VALID)) ) )
- {
- //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
- //SFX_APPWINDOW->Enable();
-
- ScPivotParam theOutParam;
- PivotPageFieldArr aPageFieldArr;
- PivotFieldArr aColFieldArr;
- PivotFieldArr aRowFieldArr;
- PivotFieldArr aDataFieldArr;
- sal_uInt16 nPageCount;
- sal_uInt16 nColCount;
- sal_uInt16 nRowCount;
- sal_uInt16 nDataCount;
-
- sal_Bool bFit = GetPivotArrays( aPageFieldArr, aColFieldArr, aRowFieldArr, aDataFieldArr,
- nPageCount, nColCount, nRowCount, nDataCount );
- if ( bFit )
+ for( ScDPLabelDataVector::const_iterator aIt = maLabelData.begin(), aEnd = maLabelData.end(); aIt != aEnd; ++aIt )
{
- ScDPSaveData* pOldSaveData = xDlgDPObject->GetSaveData();
-
- ScRange aOutRange( aAdrDest ); // bToNewTable is passed separately
-
- ScDPSaveData aSaveData;
- aSaveData.SetIgnoreEmptyRows( aBtnIgnEmptyRows.IsChecked() );
- aSaveData.SetRepeatIfEmpty( aBtnDetectCat.IsChecked() );
- aSaveData.SetColumnGrand( aBtnTotalCol.IsChecked() );
- aSaveData.SetRowGrand( aBtnTotalRow.IsChecked() );
- aSaveData.SetFilterButton( aBtnFilter.IsChecked() );
- aSaveData.SetDrillDown( aBtnDrillDown.IsChecked() );
-
- uno::Reference<sheet::XDimensionsSupplier> xSource = xDlgDPObject->GetSource();
-
- ScDPObject::ConvertOrientation( aSaveData, aPageFieldArr, nPageCount,
- sheet::DataPilotFieldOrientation_PAGE, NULL, 0, 0, xSource, sal_False );
- ScDPObject::ConvertOrientation( aSaveData, aColFieldArr, nColCount,
- sheet::DataPilotFieldOrientation_COLUMN, NULL, 0, 0, xSource, sal_False );
- ScDPObject::ConvertOrientation( aSaveData, aRowFieldArr, nRowCount,
- sheet::DataPilotFieldOrientation_ROW, NULL, 0, 0, xSource, sal_False );
- ScDPObject::ConvertOrientation( aSaveData, aDataFieldArr, nDataCount,
- sheet::DataPilotFieldOrientation_DATA, NULL, 0, 0, xSource, sal_False,
- aColFieldArr, nColCount, aRowFieldArr, nRowCount, aPageFieldArr, nPageCount );
-
- for( ScDPLabelDataVec::const_iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); aIt != aEnd; ++aIt )
+ if( ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName( aIt->maName ) )
{
- if( ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName( aIt->maName ) )
+ pDim->SetUsedHierarchy( aIt->mnUsedHier );
+ pDim->SetShowEmpty( aIt->mbShowAll );
+ pDim->SetSortInfo( &aIt->maSortInfo );
+ pDim->SetLayoutInfo( &aIt->maLayoutInfo );
+ pDim->SetAutoShowInfo( &aIt->maShowInfo );
+ ScDPSaveDimension* pOldDim = NULL;
+ if (pOldSaveData)
{
- pDim->SetUsedHierarchy( aIt->mnUsedHier );
- pDim->SetShowEmpty( aIt->mbShowAll );
- pDim->SetSortInfo( &aIt->maSortInfo );
- pDim->SetLayoutInfo( &aIt->maLayoutInfo );
- pDim->SetAutoShowInfo( &aIt->maShowInfo );
- ScDPSaveDimension* pOldDim = NULL;
- if (pOldSaveData)
+ // Transfer the existing layout names to new dimension instance.
+ pOldDim = pOldSaveData->GetExistingDimensionByName(aIt->maName);
+ if (pOldDim)
{
- // Transfer the existing layout names to new dimension instance.
- pOldDim = pOldSaveData->GetExistingDimensionByName(aIt->maName);
- if (pOldDim)
- {
- const OUString* pLayoutName = pOldDim->GetLayoutName();
- if (pLayoutName)
- pDim->SetLayoutName(*pLayoutName);
+ const OUString* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
- const OUString* pSubtotalName = pOldDim->GetSubtotalName();
- if (pSubtotalName)
- pDim->SetSubtotalName(*pSubtotalName);
- }
+ const OUString* pSubtotalName = pOldDim->GetSubtotalName();
+ if (pSubtotalName)
+ pDim->SetSubtotalName(*pSubtotalName);
}
+ }
- bool bManualSort = ( aIt->maSortInfo.Mode == sheet::DataPilotFieldSortMode::MANUAL );
+ bool bManualSort = ( aIt->maSortInfo.Mode == sheet::DataPilotFieldSortMode::MANUAL );
- // visibility of members
- for (vector<ScDPLabelData::Member>::const_iterator itr = aIt->maMembers.begin(), itrEnd = aIt->maMembers.end();
- itr != itrEnd; ++itr)
- {
- ScDPSaveMember* pMember = pDim->GetMemberByName(itr->maName);
+ // visibility of members
+ for (::std::vector<ScDPLabelData::Member>::const_iterator itr = aIt->maMembers.begin(), itrEnd = aIt->maMembers.end();
+ itr != itrEnd; ++itr)
+ {
+ ScDPSaveMember* pMember = pDim->GetMemberByName(itr->maName);
- // #i40054# create/access members only if flags are not default
- // (or in manual sorting mode - to keep the order)
- if (bManualSort || !itr->mbVisible || !itr->mbShowDetails)
- {
- pMember->SetIsVisible(itr->mbVisible);
- pMember->SetShowDetails(itr->mbShowDetails);
- }
- if (pOldDim)
+ // #i40054# create/access members only if flags are not default
+ // (or in manual sorting mode - to keep the order)
+ if (bManualSort || !itr->mbVisible || !itr->mbShowDetails)
+ {
+ pMember->SetIsVisible(itr->mbVisible);
+ pMember->SetShowDetails(itr->mbShowDetails);
+ }
+ if (pOldDim)
+ {
+ // Transfer the existing layout name.
+ ScDPSaveMember* pOldMember = pOldDim->GetMemberByName(itr->maName);
+ if (pOldMember)
{
- // Transfer the existing layout name.
- ScDPSaveMember* pOldMember = pOldDim->GetMemberByName(itr->maName);
- if (pOldMember)
- {
- const OUString* pLayoutName = pOldMember->GetLayoutName();
- if (pLayoutName)
- pMember->SetLayoutName(*pLayoutName);
- }
+ const OUString* pLayoutName = pOldMember->GetLayoutName();
+ if (pLayoutName)
+ pMember->SetLayoutName(*pLayoutName);
}
}
}
}
- ScDPSaveDimension* pDim = aSaveData.GetDataLayoutDimension();
- if (pDim && pOldSaveData)
+ }
+ ScDPSaveDimension* pDim = aSaveData.GetDataLayoutDimension();
+ if (pDim && pOldSaveData)
+ {
+ ScDPSaveDimension* pOldDim = pOldSaveData->GetDataLayoutDimension();
+ if (pOldDim)
{
- ScDPSaveDimension* pOldDim = pOldSaveData->GetDataLayoutDimension();
- if (pOldDim)
- {
- const OUString* pLayoutName = pOldDim->GetLayoutName();
- if (pLayoutName)
- pDim->SetLayoutName(*pLayoutName);
- }
+ const OUString* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
}
+ }
- sal_uInt16 nWhichPivot = SC_MOD()->GetPool().GetWhich( SID_PIVOT_TABLE );
- ScPivotItem aOutItem( nWhichPivot, &aSaveData, &aOutRange, bToNewTable );
+ sal_uInt16 nWhichPivot = SC_MOD()->GetPool().GetWhich( SID_PIVOT_TABLE );
+ ScPivotItem aOutItem( nWhichPivot, &aSaveData, &aOutRange, bToNewTable );
- bRefInputMode = sal_False; // to allow deselecting when switching sheets
+ mbRefInputMode = false; // to allow deselecting when switching sheets
- SetDispatcherLock( sal_False );
- SwitchToDocument();
+ SetDispatcherLock( false );
+ SwitchToDocument();
- // #95513# don't hide the dialog before executing the slot, instead it is used as
- // parent for message boxes in ScTabViewShell::GetDialogParent
+ // #95513# don't hide the dialog before executing the slot, instead it is used as
+ // parent for message boxes in ScTabViewShell::GetDialogParent
- const SfxPoolItem* pRet = GetBindings().GetDispatcher()->Execute(
- SID_PIVOT_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aOutItem, 0L, 0L );
+ const SfxPoolItem* pRet = GetBindings().GetDispatcher()->Execute(
+ SID_PIVOT_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aOutItem, 0L, 0L );
- bool bSuccess = true;
- if (pRet)
- {
- const SfxBoolItem* pItem = dynamic_cast<const SfxBoolItem*>(pRet);
- if (pItem)
- bSuccess = pItem->GetValue();
- }
- if (bSuccess)
- // Table successfully inserted.
- Close();
- else
- {
- // Table insertion failed. Keep the dialog open.
- bRefInputMode = true;
- SetDispatcherLock(true);
- }
+ bool bSuccess = true;
+ if (pRet)
+ {
+ const SfxBoolItem* pItem = dynamic_cast<const SfxBoolItem*>(pRet);
+ if (pItem)
+ bSuccess = pItem->GetValue();
}
+ if (bSuccess)
+ // Table successfully inserted.
+ Close();
else
{
- ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
- ScGlobal::GetRscString( STR_PIVOT_ERROR )
- ).Execute();
+ // Table insertion failed. Keep the dialog open.
+ mbRefInputMode = true;
+ SetDispatcherLock(true);
}
}
else
{
- if ( !aBtnMore.GetState() )
- aBtnMore.SetState( sal_True );
+ if( !maBtnMore.GetState() )
+ maBtnMore.SetState( true );
- ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
- ScGlobal::GetRscString( STR_INVALID_TABREF )
- ).Execute();
- aEdOutPos.GrabFocus();
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), ScGlobal::GetRscString( STR_INVALID_TABREF ) ).Execute();
+ maEdOutPos.GrabFocus();
}
return 0;
}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScDPLayoutDlg, CancelHdl, CancelButton *, EMPTYARG )
+IMPL_LINK( ScPivotLayoutDlg, CancelHdl, CancelButton *, EMPTYARG )
{
Close();
return 0;
}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScDPLayoutDlg, MoreClickHdl, MoreButton *, EMPTYARG )
+IMPL_LINK( ScPivotLayoutDlg, MoreClickHdl, MoreButton *, EMPTYARG )
{
- if ( aBtnMore.GetState() )
+ if ( maBtnMore.GetState() )
{
- bRefInputMode = sal_True;
- //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
- //SFX_APPWINDOW->Enable();
- if ( aEdInPos.IsEnabled() )
+ mbRefInputMode = true;
+ if ( maEdInPos.IsEnabled() )
{
- aEdInPos.Enable();
- aEdInPos.GrabFocus();
- aEdInPos.Enable();
+ maEdInPos.Enable();
+ maEdInPos.GrabFocus();
+ maEdInPos.Enable();
}
else
{
- aEdOutPos.Enable();
- aEdOutPos.GrabFocus();
- aEdOutPos.Enable();
+ maEdOutPos.Enable();
+ maEdOutPos.GrabFocus();
+ maEdOutPos.Enable();
}
}
else
{
- bRefInputMode = sal_False;
- //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
- //SFX_APPWINDOW->Disable(sal_False); //! allgemeine Methode im ScAnyRefDlg
+ mbRefInputMode = false;
}
return 0;
}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScDPLayoutDlg, EdModifyHdl, Edit *, EMPTYARG )
+IMPL_LINK( ScPivotLayoutDlg, EdOutModifyHdl, Edit *, EMPTYARG )
{
- String theCurPosStr = aEdOutPos.GetText();
- sal_uInt16 nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() );
+ String theCurPosStr = maEdOutPos.GetText();
+ sal_uInt16 nResult = ScAddress().Parse( theCurPosStr, mpDoc, mpDoc->GetAddressConvention() );
if ( SCA_VALID == (nResult & SCA_VALID) )
{
- String* pStr = NULL;
- sal_Bool bFound = sal_False;
- sal_uInt16 i = 0;
- sal_uInt16 nCount = aLbOutPos.GetEntryCount();
+ String* pStr = 0;
+ bool bFound = false;
+ sal_uInt16 i = 0;
+ sal_uInt16 nCount = maLbOutPos.GetEntryCount();
for ( i=2; i<nCount && !bFound; i++ )
{
- pStr = (String*)aLbOutPos.GetEntryData( i );
+ pStr = (String*)maLbOutPos.GetEntryData( i );
bFound = (theCurPosStr == *pStr);
}
if ( bFound )
- aLbOutPos.SelectEntryPos( --i );
+ maLbOutPos.SelectEntryPos( --i );
else
- aLbOutPos.SelectEntryPos( 0 );
+ maLbOutPos.SelectEntryPos( 0 );
}
return 0;
}
-IMPL_LINK( ScDPLayoutDlg, EdInModifyHdl, Edit *, EMPTYARG )
+IMPL_LINK( ScPivotLayoutDlg, EdInModifyHdl, Edit *, EMPTYARG )
{
- UpdateSrcRange();
- return 0;
-}
+ String theCurPosStr = maEdInPos.GetText();
+ sal_uInt16 nResult = ScRange().Parse( theCurPosStr, mpDoc, mpDoc->GetAddressConvention() );
+ // invalid source range
+ if( SCA_VALID != (nResult & SCA_VALID) )
+ return 0;
-//----------------------------------------------------------------------------
+ ScRefAddress start, end;
+ ConvertDoubleRef( mpDoc, theCurPosStr, 1, start, end, mpDoc->GetAddressConvention() );
+ ScRange aNewRange( start.GetAddress(), end.GetAddress() );
+ ScSheetSourceDesc inSheet = *mxDlgDPObject->GetSheetDesc();
-IMPL_LINK( ScDPLayoutDlg, SelAreaHdl, ListBox *, EMPTYARG )
-{
- String aString;
- sal_uInt16 nSelPos = aLbOutPos.GetSelectEntryPos();
+ // new range is identical to the current range
+ if( inSheet.aSourceRange == aNewRange )
+ return 0;
- if ( nSelPos > 1 )
- {
- aString = *(String*)aLbOutPos.GetEntryData( nSelPos );
- }
- else if ( nSelPos == aLbOutPos.GetEntryCount()-1 ) // auf neue Tabelle?
+ ScTabViewShell* pTabViewShell = mpViewData->GetViewShell();
+ inSheet.aSourceRange = aNewRange;
+ mxDlgDPObject->SetSheetDesc( inSheet );
+ mxDlgDPObject->FillOldParam( maPivotData );
+ mxDlgDPObject->FillLabelData( maPivotData );
+
+ // SetDialogDPObject does not take ownership but makes a copy internally
+ pTabViewShell->SetDialogDPObject( mxDlgDPObject.get() );
+
+ // re-initialize the field windows from the new data
+ InitFieldWindows();
+
+ return 0;
+}
+
+IMPL_LINK( ScPivotLayoutDlg, SelAreaHdl, ListBox *, EMPTYARG )
+{
+ String aString;
+ sal_uInt16 nSelPos = maLbOutPos.GetSelectEntryPos();
+ if( nSelPos > 1 )
{
- aEdOutPos.Disable();
- aRbOutPos.Disable();
+ aString = *(String*)maLbOutPos.GetEntryData( nSelPos );
}
else
{
- aEdOutPos.Enable();
- aRbOutPos.Enable();
+ // do not allow to specify output position, if target is "new sheet"
+ bool bNewSheet = nSelPos == 1;
+ maEdOutPos.Enable( !bNewSheet );
+ maRbOutPos.Enable( !bNewSheet );
}
- aEdOutPos.SetText( aString );
+ maEdOutPos.SetText( aString );
return 0;
}
-
-//----------------------------------------------------------------------------
-
-IMPL_LINK( ScDPLayoutDlg, ScrollHdl, ScrollBar *, EMPTYARG )
+IMPL_LINK( ScPivotLayoutDlg, ChildEventListener, VclWindowEvent*, pEvent )
{
- long nNewOffset = aSlider.GetThumbPos();
- long nOffsetDiff = nNewOffset - nOffset;
- nOffset = nNewOffset;
-
- size_t nFields = std::min< size_t >( aLabelDataArr.size() - nOffset, PAGE_SIZE );
-
- aWndSelect.ClearFields();
-
- size_t i=0;
- for ( i=0; i<nFields; i++ )
+ Window* pWindow = pEvent->GetWindow();
+ // check that this dialog is the parent of the window, to ignore focus events from sub dialogs
+ if( (pEvent->GetId() == VCLEVENT_WINDOW_GETFOCUS) && pWindow && (pWindow->GetParent() == this) )
{
- const ScDPLabelData& rData = aLabelDataArr[nOffset+i];
- aWndSelect.AddField(rData.getDisplayName(), i);
- aSelectArr[i].reset( new ScDPFuncData( rData.mnCol, rData.mnFuncMask ) );
- }
- for ( ; i<aSelectArr.size(); i++ )
- aSelectArr[i].reset();
-
- aWndSelect.ModifySelectionOffset( nOffsetDiff ); // adjusts selection & redraws
- return 0;
-}
+ // check if old window and/or new window are field windows
+ ScPivotFieldWindow* pSourceWindow = mpFocusWindow;
+ ScPivotFieldWindow* pTargetWindow = dynamic_cast< ScPivotFieldWindow* >( pWindow );
-//----------------------------------------------------------------------------
+ /* Enable or disable the Remove/Options buttons. Do nothing if the
+ buttons themselves get the focus.
+ #128113# The TestTool may set the focus into an empty window. Then
+ the Remove/Options buttons must be disabled. */
+ if( (pWindow != &maBtnRemove) && (pWindow != &maBtnOptions) )
+ {
+ bool bEnableButtons = pTargetWindow && (pTargetWindow->GetType() != PIVOTFIELDTYPE_SELECT) && !pTargetWindow->IsEmpty();
+ maBtnRemove.Enable( bEnableButtons );
+ maBtnOptions.Enable( bEnableButtons );
+ /* Remember the new focus window (will not be changed, if
+ Remove/Option buttons are getting focus, because they need to
+ know the field window they are working on). */
+ mpFocusWindow = pTargetWindow;
+ }
-IMPL_LINK( ScDPLayoutDlg, GetFocusHdl, Control*, pCtrl )
-{
- pEditActive = NULL;
- if ( pCtrl == &aEdInPos )
- pEditActive = &aEdInPos;
- else if ( pCtrl == &aEdOutPos )
- pEditActive = &aEdOutPos;
+ /* Move the last selected field to target window, if focus changes via
+ keyboard shortcut. */
+ if( pSourceWindow && pTargetWindow && (pSourceWindow != pTargetWindow) && ((pTargetWindow->GetGetFocusFlags() & GETFOCUS_MNEMONIC) != 0) )
+ {
+ // append field in target window
+ MoveField( *pSourceWindow, *pTargetWindow, pTargetWindow->GetFieldCount(), false );
+ // move cursor in selection window to next field
+ if( pSourceWindow->GetType() == PIVOTFIELDTYPE_SELECT )
+ pSourceWindow->SelectNextField();
+ // return focus to source window (if it is not empty)
+ GrabFieldFocus( pSourceWindow->IsEmpty() ? *pTargetWindow : *pSourceWindow );
+ }
+ mpActiveEdit = dynamic_cast< ::formula::RefEdit* >( pEvent->GetWindow() );
+ }
return 0;
}
+// ============================================================================
diff --git a/sc/source/ui/dbgui/scendlg.cxx b/sc/source/ui/dbgui/scendlg.cxx
index f1f35a4fbf48..080c80e509ea 100644
--- a/sc/source/ui/dbgui/scendlg.cxx
+++ b/sc/source/ui/dbgui/scendlg.cxx
@@ -117,6 +117,8 @@ ScNewScenarioDlg::ScNewScenarioDlg( Window* pParent, const String& rName, sal_Bo
aBtnOk .SetClickHdl( LINK( this, ScNewScenarioDlg, OkHdl ) );
aCbShowFrame.SetClickHdl( LINK( this, ScNewScenarioDlg, EnableHdl ) );
+ aLbColor.SetAccessibleName(String(ScResId( STR_COLOR ) ));
+
FreeResource();
aLbColor.SelectEntry( Color( COL_LIGHTGRAY ) );
@@ -142,6 +144,9 @@ ScNewScenarioDlg::ScNewScenarioDlg( Window* pParent, const String& rName, sal_Bo
aCbAttrib.Enable(sal_False);
aCbValue.Enable(sal_False);
*/
+
+ aEdComment.SetAccessibleRelationMemberOf(&aFlComment);
+ aLbColor.SetAccessibleRelationLabeledBy(&aCbShowFrame);
}
//------------------------------------------------------------------------
diff --git a/sc/source/ui/dbgui/scendlg.hrc b/sc/source/ui/dbgui/scendlg.hrc
index 83818773bf5a..f7fa562a5b17 100644
--- a/sc/source/ui/dbgui/scendlg.hrc
+++ b/sc/source/ui/dbgui/scendlg.hrc
@@ -55,3 +55,6 @@
#define STR_CREATEDBY 31
#define STR_ON 32
#define STR_EDIT 33
+//IAccessibility2 Implementation 2009-----
+#define STR_COLOR 34
+//-----IAccessibility2 Implementation 2009
diff --git a/sc/source/ui/dbgui/scendlg.src b/sc/source/ui/dbgui/scendlg.src
index f7c3d29b8365..640fdda8bc30 100644
--- a/sc/source/ui/dbgui/scendlg.src
+++ b/sc/source/ui/dbgui/scendlg.src
@@ -147,6 +147,10 @@ ModalDialog RID_SCDLG_NEWSCENARIO
{
Text [ en-US ] = "on" ;
};
+ String STR_COLOR
+ {
+ Text [ en-US ] = "Display border in" ;
+ };
FixedLine FL_NAME
{
Pos = MAP_APPFONT ( 6 , 3 ) ;
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index abbda7b995e7..2cf981a15ff3 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -273,7 +273,7 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
OUString sTextSeparators;
bool bMergeDelimiters = false;
bool bFixedWidth = false;
- bool bQuotedFieldAsText = true;
+ bool bQuotedFieldAsText = false;
bool bDetectSpecialNum = false;
sal_Int32 nFromRow = 1;
sal_Int32 nCharSet = -1;
@@ -316,34 +316,45 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
maFieldSeparators = GetSeparators();
// Clipboard is always Unicode, else detect.
- bool bPreselectUnicode = !mbFileImport;
+ rtl_TextEncoding ePreselectUnicode = (mbFileImport ?
+ RTL_TEXTENCODING_DONTKNOW : RTL_TEXTENCODING_UNICODE);
// Sniff for Unicode / not
- if( !bPreselectUnicode && mpDatStream )
+ if( ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW && mpDatStream )
{
Seek( 0 );
- mpDatStream->StartReadingUnicodeText();
+ mpDatStream->StartReadingUnicodeText( RTL_TEXTENCODING_DONTKNOW );
sal_uLong nUniPos = mpDatStream->Tell();
- if ( nUniPos > 0 )
- bPreselectUnicode = sal_True; // read 0xfeff/0xfffe
- else
+ switch (nUniPos)
{
- sal_uInt16 n;
- *mpDatStream >> n;
- // Assume that normal ASCII/ANSI/ISO/etc. text doesn't start with
- // control characters except CR,LF,TAB
- if ( (n & 0xff00) < 0x2000 )
- {
- switch ( n & 0xff00 )
+ case 2:
+ ePreselectUnicode = RTL_TEXTENCODING_UNICODE; // UTF-16
+ break;
+ case 3:
+ ePreselectUnicode = RTL_TEXTENCODING_UTF8; // UTF-8
+ break;
+ case 0:
{
- case 0x0900 :
- case 0x0a00 :
- case 0x0d00 :
- break;
- default:
- bPreselectUnicode = sal_True;
+ sal_uInt16 n;
+ *mpDatStream >> n;
+ // Assume that normal ASCII/ANSI/ISO/etc. text doesn't start with
+ // control characters except CR,LF,TAB
+ if ( (n & 0xff00) < 0x2000 )
+ {
+ switch ( n & 0xff00 )
+ {
+ case 0x0900 :
+ case 0x0a00 :
+ case 0x0d00 :
+ break;
+ default:
+ ePreselectUnicode = RTL_TEXTENCODING_UNICODE; // UTF-16
+ }
+ }
+ mpDatStream->Seek(0);
}
- }
- mpDatStream->Seek(0);
+ break;
+ default:
+ ; // nothing
}
mnStreamPos = mpDatStream->Tell();
}
@@ -373,10 +384,10 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
// Insert one "SYSTEM" entry for compatibility in AsciiOptions and system
// independent document linkage.
aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
- aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
- RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
+ aLbCharSet.SelectTextEncoding( ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW ?
+ gsl_getSystemTextEncoding() : ePreselectUnicode );
- if( nCharSet >= 0 )
+ if( nCharSet >= 0 && ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW )
aLbCharSet.SelectEntryPos( static_cast<sal_uInt16>(nCharSet) );
SetSelectedCharSet();
@@ -410,6 +421,9 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
UpdateVertical();
maTableBox.Execute( CSVCMD_NEWCELLTEXTS );
+
+ aEdOther.SetAccessibleName(aCkbOther.GetText());
+ aEdOther.SetAccessibleRelationLabeledBy(&aCkbOther);
}
@@ -437,8 +451,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, String &rText )
memset( mpRowPosArray, 0, sizeof(mpRowPosArray[0]) * (ASCIIDLG_MAXROWS+2));
Seek(0);
- if ( mpDatStream->GetStreamCharSet() == RTL_TEXTENCODING_UNICODE )
- mpDatStream->StartReadingUnicodeText();
+ mpDatStream->StartReadingUnicodeText( mpDatStream->GetStreamCharSet() );
mnStreamPos = mpDatStream->Tell();
mpRowPosArray[mnRowPosCount] = mnStreamPos;
diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx
index 3bca3a8ade22..486704ca4d12 100644
--- a/sc/source/ui/dbgui/scuiimoptdlg.cxx
+++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx
@@ -132,11 +132,12 @@ ScImportOptionsDlg::ScImportOptionsDlg(
aEdFieldSep ( this, ScResId( ED_FIELDSEP ) ),
aFtTextSep ( this, ScResId( FT_TEXTSEP ) ),
aEdTextSep ( this, ScResId( ED_TEXTSEP ) ),
+ aCbQuoteAll ( this, ScResId( CB_QUOTEALL ) ),
+ aCbShown ( this, ScResId( CB_SAVESHOWN ) ),
aCbFixed ( this, ScResId( CB_FIXEDWIDTH ) ),
aBtnOk ( this, ScResId( BTN_OK ) ),
aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- aBtnHelp ( this, ScResId( BTN_HELP ) ),
- aCbShown ( this, ScResId( CB_SAVESHOWN ) )
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
{
// im Ctor-Initializer nicht moeglich (MSC kann das nicht):
pFieldSepTab = new ScDelimiterTable( String(ScResId(SCSTR_FIELDSEP)) );
@@ -214,6 +215,8 @@ ScImportOptionsDlg::ScImportOptionsDlg(
aCbFixed.Check( sal_False );
aCbShown.Show();
aCbShown.Check( sal_True );
+ aCbQuoteAll.Show();
+ aCbQuoteAll.Check( sal_False );
}
else
{
@@ -225,6 +228,7 @@ ScImportOptionsDlg::ScImportOptionsDlg(
aEdTextSep.Hide();
aCbFixed.Hide();
aCbShown.Hide();
+ aCbQuoteAll.Hide();
aLbFont.GrabFocus();
aLbFont.SetDoubleClickHdl( LINK( this, ScImportOptionsDlg, DoubleClickHdl ) );
}
@@ -259,6 +263,7 @@ void ScImportOptionsDlg::GetImportOptions( ScImportOptions& rOptions ) const
rOptions.nTextSepCode = GetCodeFromCombo( aEdTextSep );
rOptions.bFixedWidth = aCbFixed.IsChecked();
rOptions.bSaveAsShown = aCbShown.IsChecked();
+ rOptions.bQuoteAllText = aCbQuoteAll.IsChecked();
}
}
@@ -302,6 +307,7 @@ IMPL_LINK( ScImportOptionsDlg, FixedWidthHdl, CheckBox*, pCheckBox )
aFtTextSep.Enable( bEnable );
aEdTextSep.Enable( bEnable );
aCbShown.Enable( bEnable );
+ aCbQuoteAll.Enable( bEnable );
}
return 0;
}
diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx
index 24751946253f..7e0b53d863cc 100644
--- a/sc/source/ui/dbgui/sfiltdlg.cxx
+++ b/sc/source/ui/dbgui/sfiltdlg.cxx
@@ -70,8 +70,8 @@ ScSpecialFilterDlg::ScSpecialFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Wi
: ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SPEC_FILTER ),
//
- aLbFilterArea ( this, ScResId( LB_CRITERIA_AREA ) ),
aFtFilterArea ( this, ScResId( FT_CRITERIA_AREA ) ),
+ aLbFilterArea ( this, ScResId( LB_CRITERIA_AREA ) ),
aEdFilterArea ( this, this, ScResId( ED_CRITERIA_AREA ) ),
aRbFilterArea ( this, ScResId( RB_CRITERIA_AREA ), &aEdFilterArea, this ),
//
@@ -103,6 +103,11 @@ ScSpecialFilterDlg::ScSpecialFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Wi
pTimer->SetTimeout( 50 ); // 50ms warten
pTimer->SetTimeoutHdl( LINK( this, ScSpecialFilterDlg, TimeOutHdl ) );
pTimer->Start();
+
+ aLbCopyArea.SetAccessibleName(aBtnCopyResult.GetText());
+ aEdCopyArea.SetAccessibleName(aBtnCopyResult.GetText());
+ aLbCopyArea.SetAccessibleRelationLabeledBy(&aBtnCopyResult);
+ aEdCopyArea.SetAccessibleRelationLabeledBy(&aBtnCopyResult);
}
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 65411f7f82d2..2bf85de61a0b 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -600,6 +600,13 @@ ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent,
Init();
FreeResource();
SetExchangeSupport();
+
+ aLbOutPos.SetAccessibleRelationLabeledBy(&aBtnCopyResult);
+ aLbOutPos.SetAccessibleName(aBtnCopyResult.GetText());
+ aEdOutPos.SetAccessibleRelationLabeledBy(&aBtnCopyResult);
+ aEdOutPos.SetAccessibleName(aBtnCopyResult.GetText());
+ aLbSortUser.SetAccessibleRelationLabeledBy(&aBtnSortUser);
+ aLbSortUser.SetAccessibleName(aBtnSortUser.GetText());
}
// -----------------------------------------------------------------------
diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx
index 070167f8ff95..d2f4db3cde07 100644
--- a/sc/source/ui/dbgui/tpsubt.cxx
+++ b/sc/source/ui/dbgui/tpsubt.cxx
@@ -523,6 +523,9 @@ ScTpSubTotalOptions::ScTpSubTotalOptions( Window* pParent,
{
Init();
FreeResource();
+
+ aLbUserDef.SetAccessibleRelationLabeledBy(&aBtnUserDef);
+ aLbUserDef.SetAccessibleName(aBtnUserDef.GetText());
}
// -----------------------------------------------------------------------