Kaydet (Commit) 08cc1553 authored tarafından Caolán McNamara's avatar Caolán McNamara

adapt code to use converted share doument widget

Change-Id: Ic553e593890cb3254666e3c27c5d8ca05256687e
üst 10bd0604
......@@ -84,7 +84,6 @@ $(eval $(call gb_SrsTarget_add_files,sc/res,\
sc/source/ui/miscdlgs/conflictsdlg.src \
sc/source/ui/miscdlgs/protectiondlg.src \
sc/source/ui/miscdlgs/acredlin.src \
sc/source/ui/miscdlgs/sharedocdlg.src \
sc/source/ui/formdlg/formdlgs.src \
sc/source/ui/formdlg/dwfunctr.src \
sc/source/core/src/compiler.src \
......
......@@ -75,6 +75,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/sheetprintpage \
sc/uiconfig/scalc/ui/selectrange \
sc/uiconfig/scalc/ui/selectsource \
sc/uiconfig/scalc/ui/sharedocumentdlg \
sc/uiconfig/scalc/ui/solverdlg \
sc/uiconfig/scalc/ui/sortcriteriapage \
sc/uiconfig/scalc/ui/sortkey \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sc.hrc>
#define CB_SHARE 1
#define FT_WARNING 2
#define FL_USERS 3
#define FT_USERS 4
#define LB_USERS 5
#define FL_END 6
#define BTN_HELP 7
#define BTN_OK 8
#define BTN_CANCEL 9
#define STR_TITLE_NAME 1
#define STR_TITLE_ACCESSED 2
#define STR_NO_USER_DATA 3
#define STR_UNKNOWN_USER 4
#define STR_EXCLUSIVE_ACCESS 5
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -36,22 +36,13 @@ class ScDocShell;
class ScShareDocumentDlg : public ModalDialog
{
private:
CheckBox maCbShare;
FixedText maFtWarning;
FixedLine maFlUsers;
FixedText maFtUsers;
SvxSimpleTableContainer m_aLbUsersContainer;
SvxSimpleTable maLbUsers;
FixedLine maFlEnd;
HelpButton maBtnHelp;
OKButton maBtnOK;
CancelButton maBtnCancel;
CheckBox* m_pCbShare;
FixedText* m_pFtWarning;
SvxSimpleTable* m_pLbUsers;
String maStrTitleName;
String maStrTitleAccessed;
String maStrNoUserData;
String maStrUnkownUser;
String maStrExclusiveAccess;
OUString m_aStrNoUserData;
OUString m_aStrUnknownUser;
OUString m_aStrExclusiveAccess;
ScViewData* mpViewData;
ScDocShell* mpDocShell;
......
......@@ -28,7 +28,6 @@
#include "sharedocdlg.hxx"
#include "sharedocdlg.hrc"
#include "scresid.hxx"
#include "docsh.hxx"
#include "viewdata.hxx"
......@@ -36,68 +35,101 @@
using namespace ::com::sun::star;
class ScShareTable : public SvxSimpleTable
{
private:
OUString m_sWidestAccessString;
public:
ScShareTable(SvxSimpleTableContainer& rParent)
: SvxSimpleTable(rParent)
{
Date aDate(22, 12, 2000);
Time aTime(22, 59);
DateTime aDateTime(aDate, aTime);
m_sWidestAccessString += ScGlobal::pLocaleData->getDate(aDateTime);
m_sWidestAccessString += OUString(' ');
m_sWidestAccessString += ScGlobal::pLocaleData->getTime(aDateTime, false);
}
virtual void Resize()
{
SvxSimpleTable::Resize();
if (isInitialLayout(this))
setColWidths();
}
void setColWidths()
{
HeaderBar &rBar = GetTheHeaderBar();
if (rBar.GetItemCount() < 2)
return;
long nAccessedWidth = 12 +
std::max(rBar.GetTextWidth(rBar.GetItemText(2)),
GetTextWidth(m_sWidestAccessString));
long nWebSiteWidth = std::max(
12 + rBar.GetTextWidth(rBar.GetItemText(1)),
GetSizePixel().Width() - nAccessedWidth);
long aStaticTabs[]= { 2, 0, 0 };
aStaticTabs[2] = nWebSiteWidth;
SvxSimpleTable::SetTabs(aStaticTabs, MAP_PIXEL);
}
};
//=============================================================================
// class ScShareDocumentDlg
//=============================================================================
ScShareDocumentDlg::ScShareDocumentDlg( Window* pParent, ScViewData* pViewData )
:ModalDialog( pParent, ScResId( RID_SCDLG_SHAREDOCUMENT ) )
,maCbShare ( this, ScResId( CB_SHARE ) )
,maFtWarning ( this, ScResId( FT_WARNING ) )
,maFlUsers ( this, ScResId( FL_USERS ) )
,maFtUsers ( this, ScResId( FT_USERS ) )
,m_aLbUsersContainer(this, ScResId(LB_USERS))
,maLbUsers(m_aLbUsersContainer)
,maFlEnd ( this, ScResId( FL_END ) )
,maBtnHelp ( this, ScResId( BTN_HELP ) )
,maBtnOK ( this, ScResId( BTN_OK ) )
,maBtnCancel ( this, ScResId( BTN_CANCEL ) )
,maStrTitleName ( ScResId( STR_TITLE_NAME ) )
,maStrTitleAccessed ( ScResId( STR_TITLE_ACCESSED ) )
,maStrNoUserData ( ScResId( STR_NO_USER_DATA ) )
,maStrUnkownUser ( ScResId( STR_UNKNOWN_USER ) )
,maStrExclusiveAccess ( ScResId( STR_EXCLUSIVE_ACCESS ) )
,mpViewData ( pViewData )
,mpDocShell ( NULL )
: ModalDialog(pParent, "ShareDocumentDialog", "modules/scalc/ui/sharedocumentdlg.ui")
, mpViewData(pViewData)
, mpDocShell(NULL)
{
OSL_ENSURE( mpViewData, "ScShareDocumentDlg CTOR: mpViewData is null!" );
mpDocShell = ( mpViewData ? mpViewData->GetDocShell() : NULL );
OSL_ENSURE( mpDocShell, "ScShareDocumentDlg CTOR: mpDocShell is null!" );
FreeResource();
get(m_pCbShare, "share");
get(m_pFtWarning, "warning");
SvxSimpleTableContainer *pCtrl = get<SvxSimpleTableContainer>("users");
pCtrl->set_height_request(pCtrl->GetTextHeight()*9);
m_pLbUsers = new ScShareTable(*pCtrl);
m_aStrNoUserData = get<FixedText>("nouserdata")->GetText();
m_aStrUnknownUser = get<FixedText>("unknownuser")->GetText();
m_aStrExclusiveAccess = get<FixedText>("exclusive")->GetText();
bool bIsDocShared = ( mpDocShell ? mpDocShell->IsDocShared() : false );
maCbShare.Check( bIsDocShared );
maCbShare.SetToggleHdl( LINK( this, ScShareDocumentDlg, ToggleHandle ) );
maFtWarning.Enable( bIsDocShared );
m_pCbShare->Check( bIsDocShared );
m_pCbShare->SetToggleHdl( LINK( this, ScShareDocumentDlg, ToggleHandle ) );
m_pFtWarning->Enable( bIsDocShared );
long nTabs[] = { 2, 10, 128 };
maLbUsers.SetTabs( nTabs );
long nTabs[] = { 2, 0, 0 };
m_pLbUsers->SetTabs( nTabs );
String aHeader( maStrTitleName );
String aHeader(get<FixedText>("name")->GetText());
aHeader += '\t';
aHeader += maStrTitleAccessed;
maLbUsers.InsertHeaderEntry( aHeader, HEADERBAR_APPEND, HIB_LEFT | HIB_LEFTIMAGE | HIB_VCENTER );
maLbUsers.SetSelectionMode( NO_SELECTION );
aHeader += get<FixedText>("accessed")->GetText();
m_pLbUsers->InsertHeaderEntry( aHeader, HEADERBAR_APPEND, HIB_LEFT | HIB_LEFTIMAGE | HIB_VCENTER );
m_pLbUsers->SetSelectionMode( NO_SELECTION );
UpdateView();
}
ScShareDocumentDlg::~ScShareDocumentDlg()
{
delete m_pLbUsers;
}
IMPL_LINK_NOARG(ScShareDocumentDlg, ToggleHandle)
{
maFtWarning.Enable( maCbShare.IsChecked() );
m_pFtWarning->Enable( m_pCbShare->IsChecked() );
return 0;
}
bool ScShareDocumentDlg::IsShareDocumentChecked() const
{
return maCbShare.IsChecked();
return m_pCbShare->IsChecked();
}
void ScShareDocumentDlg::UpdateView()
......@@ -135,7 +167,7 @@ void ScShareDocumentDlg::UpdateView()
}
else
{
aUser = OUString(maStrUnkownUser) + " " + OUString::number( nUnknownUser++ );
aUser = OUString(m_aStrUnknownUser) + " " + OUString::number( nUnknownUser++ );
}
// parse the edit time string of the format "DD.MM.YYYY hh:mm"
......@@ -160,20 +192,20 @@ void ScShareDocumentDlg::UpdateView()
aString += ' ';
aString += ScGlobal::pLocaleData->getTime( aDateTime, false );
maLbUsers.InsertEntry( aString, NULL );
m_pLbUsers->InsertEntry( aString, NULL );
}
}
}
else
{
maLbUsers.InsertEntry( maStrNoUserData, NULL );
m_pLbUsers->InsertEntry( m_aStrNoUserData, NULL );
}
}
catch ( uno::Exception& )
{
OSL_FAIL( "ScShareDocumentDlg::UpdateView(): caught exception\n" );
maLbUsers.Clear();
maLbUsers.InsertEntry( maStrNoUserData, NULL );
m_pLbUsers->Clear();
m_pLbUsers->InsertEntry( m_aStrNoUserData, NULL );
}
}
else
......@@ -197,10 +229,10 @@ void ScShareDocumentDlg::UpdateView()
if ( aUser.Len() == 0 )
{
// unknown user name
aUser = maStrUnkownUser;
aUser = m_aStrUnknownUser;
}
aUser += ' ';
aUser += maStrExclusiveAccess;
aUser += m_aStrExclusiveAccess;
String aString( aUser );
aString += '\t';
......@@ -216,7 +248,7 @@ void ScShareDocumentDlg::UpdateView()
aString += ' ';
aString += ScGlobal::pLocaleData->getTime( aDateTime, false );
maLbUsers.InsertEntry( aString, NULL );
m_pLbUsers->InsertEntry( aString, NULL );
}
}
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "sharedocdlg.hrc"
ModalDialog RID_SCDLG_SHAREDOCUMENT
{
OutputSize = TRUE ;
HelpId = CMD_SID_SHARE_DOC ;
SVLook = TRUE ;
Size = MAP_APPFONT ( 204 , 186 ) ;
Text [ en-US ] = "Share Document" ;
Moveable = TRUE ;
Closeable = TRUE ;
CheckBox CB_SHARE
{
HelpID = "sc:CheckBox:RID_SCDLG_SHAREDOCUMENT:CB_SHARE";
Pos = MAP_APPFONT ( 6 , 6 ) ;
Size = MAP_APPFONT ( 192 , 8 ) ;
Text [ en-US ] = "Share this spreadsheet with other users" ;
};
FixedText FT_WARNING
{
Pos = MAP_APPFONT ( 15 , 18 ) ;
Size = MAP_APPFONT ( 183 , 48 ) ;
WordBreak = TRUE ;
Text [ en-US ] = "Note: Changes to formatting attributes like fonts, colors, and number formats will not be saved and some functionalities like editing charts and drawing objects are not available in shared mode. Turn off shared mode to get exclusive access needed for those changes and functionalities." ;
};
FixedLine FL_USERS
{
Pos = MAP_APPFONT ( 6 , 66 ) ;
Size = MAP_APPFONT ( 192 , 4 ) ;
};
FixedText FT_USERS
{
Pos = MAP_APPFONT ( 6 , 72 ) ;
Size = MAP_APPFONT ( 192 , 8 ) ;
Text [ en-US ] = "Users currently accessing this spreadsheet" ;
};
Control LB_USERS
{
Pos = MAP_APPFONT ( 6 , 82 ) ;
Size = MAP_APPFONT ( 192 , 72 ) ;
Border = TRUE ;
};
FixedLine FL_END
{
Pos = MAP_APPFONT ( 1 , 156 ) ;
Size = MAP_APPFONT ( 204 , 8 ) ;
};
HelpButton BTN_HELP
{
Pos = MAP_APPFONT ( 6 , 166 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
};
OKButton BTN_OK
{
Pos = MAP_APPFONT ( 92 , 166 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
DefButton = TRUE ;
};
CancelButton BTN_CANCEL
{
Pos = MAP_APPFONT ( 148 , 166 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
};
String STR_TITLE_NAME
{
Text [ en-US ] = "Name" ;
};
String STR_TITLE_ACCESSED
{
Text [ en-US ] = "Accessed" ;
};
String STR_NO_USER_DATA
{
Text [ en-US ] = "No user data available." ;
};
String STR_UNKNOWN_USER
{
Text [ en-US ] = "Unknown User" ;
};
String STR_EXCLUSIVE_ACCESS
{
Text [ en-US ] = "(exclusive access)" ;
};
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment